Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion scripts/create_baseline_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down
18 changes: 10 additions & 8 deletions scripts/install_all_third_party_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion tests/mypy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down