Exemplo n.º 1
0
    def run(
            self,
            pex,  # type: PEX
            options,  # type: Namespace
    ):
        # type: (...) -> Result

        venv_dir = options.venv[0]
        venv = Virtualenv.create(venv_dir,
                                 interpreter=pex.interpreter,
                                 force=options.force,
                                 copies=options.copies)
        populate_venv_with_pex(
            venv,
            pex,
            bin_path=BinPath.for_value(options.bin_path),
            collisions_ok=options.collisions_ok,
        )
        if options.pip:
            try:
                venv.install_pip()
            except PipUnavailableError as e:
                return Error(
                    "The virtual environment was successfully created, but Pip was not "
                    "installed:\n{}".format(e))
        if options.compile:
            pex.interpreter.execute(["-m", "compileall", venv_dir])
        return Ok()
Exemplo n.º 2
0
    def PEX_VENV_BIN_PATH(self):
        # type: () -> BinPath.Value
        """String (false|prepend|append).

        When running in PEX_VENV mode, optionally add the scripts and console scripts of
        distributions in the PEX file to the $PATH.

        Default: false.
        """
        return BinPath.for_value(self._get_string("PEX_VENV_BIN_PATH"))
Exemplo n.º 3
0
 def __call__(self, parser, namespace, value, option_str=None):
     bin_path = BinPath.FALSE if value is None else BinPath.for_value(value)
     setattr(namespace, self.dest, bin_path)
Exemplo n.º 4
0
 def venv_bin_path(self):
     # type: () -> BinPath.Value
     """When run as a venv, whether or not to include `bin/` scripts on the PATH."""
     return BinPath.for_value(
         self._pex_info.get("venv_bin_path", BinPath.FALSE.value))