Update pip install calls in scripts to use uv. And messages to reference current executable (#13597)

This commit is contained in:
Avasam
2025-03-27 04:55:38 -04:00
committed by GitHub
parent 4fff7b7d01
commit 11929debd4
4 changed files with 19 additions and 10 deletions
+3 -1
View File
@@ -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
@@ -3,11 +3,13 @@ import sys
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()
+1 -1
View File
@@ -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
+6 -1
View File
@@ -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():