Pass Requirement objects around (#12709)

This allows us to keep metadata like python_version and platform_system
and use it to conditionally install packages.
This commit is contained in:
Sebastian Rittau
2024-09-30 17:45:58 +02:00
committed by GitHub
parent 06b50fcc27
commit 3b385903a1
6 changed files with 47 additions and 41 deletions
+4 -2
View File
@@ -139,13 +139,15 @@ def setup_testcase_dir(package: DistributionTests, tempdir: Path, verbosity: Ver
# mypy refuses to consider a directory a "valid typeshed directory"
# unless there's a stubs/mypy-extensions path inside it,
# so add that to the list of stubs to copy over to the new directory
for requirement in {package.name, *requirements.typeshed_pkgs, "mypy-extensions"}:
typeshed_requirements = [r.name for r in requirements.typeshed_pkgs]
for requirement in {package.name, *typeshed_requirements, "mypy-extensions"}:
shutil.copytree(Path("stubs", requirement), new_typeshed / "stubs" / requirement)
if requirements.external_pkgs:
venv_location = str(tempdir / VENV_DIR)
subprocess.run(["uv", "venv", venv_location], check=True, capture_output=True)
uv_command = ["uv", "pip", "install", get_mypy_req(), *requirements.external_pkgs]
ext_requirements = [str(r) for r in requirements.external_pkgs]
uv_command = ["uv", "pip", "install", get_mypy_req(), *ext_requirements]
if sys.platform == "win32":
# Reads/writes to the cache are threadsafe with uv generally...
# but not on old Windows versions