MCPcopy Index your code
hub / github.com/python/mypy / install_package

Function install_package

mypy/test/testpep561.py:66–88  ·  view source on GitHub ↗

Install a package from test-data/packages/pkg/

(
    pkg: str, python_executable: str = sys.executable, editable: bool = False
)

Source from the content-addressed store, hash-verified

64
65
66def install_package(
67 pkg: str, python_executable: str = sys.executable, editable: bool = False
68) -> None:
69 """Install a package from test-data/packages/pkg/"""
70 working_dir = os.path.join(package_path, pkg)
71 with tempfile.TemporaryDirectory() as dir:
72 install_cmd = [python_executable, "-m", "pip", "install"]
73 if editable:
74 install_cmd.append("-e")
75 install_cmd.append(".")
76
77 # Note that newer versions of pip (21.3+) don't
78 # follow this env variable, but this is for compatibility
79 env = {"PIP_BUILD": dir}
80 # Inherit environment for Windows
81 env.update(os.environ)
82 try:
83 with filelock.FileLock(pip_lock, timeout=pip_timeout):
84 proc = subprocess.run(install_cmd, cwd=working_dir, capture_output=True, env=env)
85 except filelock.Timeout as err:
86 raise Exception(f"Failed to acquire {pip_lock}") from err
87 if proc.returncode != 0:
88 raise Exception(proc.stdout.decode("utf-8") + proc.stderr.decode("utf-8"))
89
90
91def test_pep561(testcase: DataDrivenTestCase) -> None:

Callers 1

test_pep561Function · 0.85

Calls 6

ExceptionClass · 0.85
appendMethod · 0.80
joinMethod · 0.45
updateMethod · 0.45
runMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…