diff --git a/scripts/create_baseline_stubs.py b/scripts/create_baseline_stubs.py index 3766266adc91..2aab6aea5710 100755 --- a/scripts/create_baseline_stubs.py +++ b/scripts/create_baseline_stubs.py @@ -46,6 +46,8 @@ def get_installed_package_info(project: str) -> tuple[str, str] | None: Return (normalized project name, installed version) if successful. """ + # Not using "uv pip freeze" because if this is run from a global Python, + # it'll mistakenly list the .venv's packages. r = subprocess.run(["pip", "freeze"], capture_output=True, text=True, check=True) return search_pip_freeze_output(project, r.stdout) @@ -220,7 +222,7 @@ def main() -> None: if info is None: print(f'Error: "{project}" is not installed', file=sys.stderr) print(file=sys.stderr) - print(f'Suggestion: Run "python3 -m pip install {project}" and try again', file=sys.stderr) + print(f"Suggestion: Run `{sys.executable} -m pip install {project}` and try again", file=sys.stderr) sys.exit(1) project, version = info diff --git a/scripts/install_all_third_party_dependencies.py b/scripts/install_all_third_party_dependencies.py index a11238da8199..ca1b7075589f 100644 --- a/scripts/install_all_third_party_dependencies.py +++ b/scripts/install_all_third_party_dependencies.py @@ -3,11 +3,13 @@ from ts_utils.requirements import get_external_stub_requirements -use_uv = "--uv" in sys.argv -if use_uv: - pip_command = ["uv", "pip", "install"] -else: - pip_command = ["pip", "install"] - -requirements = get_external_stub_requirements() -subprocess.check_call(pip_command + [str(requirement) for requirement in requirements]) + +def main() -> None: + requirements = get_external_stub_requirements() + # By forwarding arguments, we naturally allow non-venv (system installs) + # by letting the script's user follow uv's own helpful hint of passing the `--system` flag. + subprocess.check_call(["uv", "pip", "install", *sys.argv[1:], *[str(requirement) for requirement in requirements]]) + + +if __name__ == "__main__": + main() diff --git a/tests/mypy_test.py b/tests/mypy_test.py index b5e91bd8af58..f292b47f4e6c 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -507,7 +507,7 @@ def setup_virtual_environments(distributions: dict[str, PackageDependencies], ar print(colored(f"took {venv_elapsed_time:.2f} seconds", "blue")) # STAGE 3: For each {virtual_environment: requirements_set} pairing, - # `pip install` the requirements set into the virtual environment + # `uv pip install` the requirements set into the virtual environment pip_start_time = time.perf_counter() # Limit workers to 10 at a time, since this makes network requests diff --git a/tests/runtests.py b/tests/runtests.py index e0aad9e95bd2..47be0830ba67 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -124,7 +124,12 @@ def main() -> None: print("\nRunning pytype...") pytype_result = subprocess.run([sys.executable, "tests/pytype_test.py", path]) else: - print(colored("\nSkipping pytype on Windows. You need to install it first: `pip install pytype`.", "yellow")) + print( + colored( + f"\nSkipping pytype on Windows. You need to install it first: `{sys.executable} -m pip install pytype` .", + "yellow", + ) + ) cases_path = test_cases_path(stub if folder == "stubs" else "stdlib") if not cases_path.exists():