Skip to content

Commit

Permalink
Use uv to install packages into venvs in regr_test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Feb 16, 2024
1 parent cb27610 commit 3597f22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ termcolor>=2.3
tomli==2.0.1
tomlkit==0.12.3
typing_extensions>=4.9.0rc1
uv

# Type stubs used to type check our scripts.
types-pyyaml>=6.0.12.7
11 changes: 7 additions & 4 deletions tests/regr_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,16 @@ def setup_testcase_dir(package: PackageInfo, tempdir: Path, verbosity: Verbosity
shutil.copytree(Path("stubs", requirement), new_typeshed / "stubs" / requirement)

if requirements.external_pkgs:
pip_exe = make_venv(tempdir / VENV_DIR).pip_exe
venv_location = str(tempdir / VENV_DIR)
subprocess.run(["uv", "venv", venv_location], check=True)
# Use --no-cache-dir to avoid issues with concurrent read/writes to the cache
pip_command = [pip_exe, "install", get_mypy_req(), *requirements.external_pkgs, "--no-cache-dir"]
uv_command = ["uv", "pip", "install", get_mypy_req(), *requirements.external_pkgs, "--no-cache-dir"]
if verbosity is Verbosity.VERBOSE:
verbose_log(f"{package.name}: Setting up venv in {tempdir / VENV_DIR}. {pip_command=}\n")
verbose_log(f"{package.name}: Setting up venv in {venv_location}. {uv_command=}\n")
try:
subprocess.run(pip_command, check=True, capture_output=True, text=True)
subprocess.run(
uv_command, check=True, capture_output=True, text=True, env=os.environ | {"VIRTUAL_ENV": venv_location}
)
except subprocess.CalledProcessError as e:
_PRINT_QUEUE.put(f"{package.name}\n{e.stderr}")
raise
Expand Down

0 comments on commit 3597f22

Please sign in to comment.