MCPcopy Index your code
hub / github.com/pex-tool/pex / ensure_python_venv

Function ensure_python_venv

testing/__init__.py:795–818  ·  view source on GitHub ↗
(
    version,  # type: str
    latest_pip=True,  # type: bool
    system_site_packages=False,  # type: bool
    tmpdir=None,  # type: Optional[Tempdir]
)

Source from the content-addressed store, hash-verified

793
794
795def ensure_python_venv(
796 version, # type: str
797 latest_pip=True, # type: bool
798 system_site_packages=False, # type: bool
799 tmpdir=None, # type: Optional[Tempdir]
800):
801 # type: (...) -> Virtualenv
802 pyenv_distribution = ensure_python_distribution(version)
803 venv = tmpdir.join("{version}.venv".format(version=version)) if tmpdir else safe_mkdtemp()
804 if _ALL_PY_VERSIONS_TO_VERSION_INFO[version][0] == 3:
805 args = [pyenv_distribution.binary, "-m", "venv", venv]
806 if system_site_packages:
807 args.append("--system-site-packages")
808 subprocess.check_call(args=args)
809 else:
810 subprocess.check_call(args=[pyenv_distribution.pip, "install", "virtualenv==16.7.10"])
811 args = [pyenv_distribution.binary, "-m", "virtualenv", venv, "-q"]
812 if system_site_packages:
813 args.append("--system-site-packages")
814 subprocess.check_call(args=args)
815 python, pip = tuple(os.path.join(venv, "bin", exe) for exe in ("python", "pip"))
816 if latest_pip:
817 subprocess.check_call(args=[pip, "install", "-U", "pip"])
818 return Virtualenv(venv)
819
820
821def ensure_python_interpreter(version):

Callers 8

test_extract_lifecycleFunction · 0.90
test_extras_isolationFunction · 0.90
test_excludeFunction · 0.90
test_extras_isolationFunction · 0.90
test_data_filesFunction · 0.90
all_python_venvsFunction · 0.85

Calls 4

safe_mkdtempFunction · 0.90
appendMethod · 0.80
joinMethod · 0.45

Tested by 7

test_extract_lifecycleFunction · 0.72
test_extras_isolationFunction · 0.72
test_excludeFunction · 0.72
test_extras_isolationFunction · 0.72
test_data_filesFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…