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 _create_pex_venv(*options):
     # type: (*str) -> Virtualenv
     subprocess.check_call(args=[pex, "venv", venv_dir] +
                           list(options or ()),
                           env=make_env(PEX_TOOLS="1"))
     return Virtualenv(venv_dir)