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()