Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 11929de

Browse files
authored
Update pip install calls in scripts to use uv. And messages to reference current executable (#13597)
1 parent 4fff7b7 commit 11929de

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

scripts/create_baseline_stubs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def get_installed_package_info(project: str) -> tuple[str, str] | None:
4646
4747
Return (normalized project name, installed version) if successful.
4848
"""
49+
# Not using "uv pip freeze" because if this is run from a global Python,
50+
# it'll mistakenly list the .venv's packages.
4951
r = subprocess.run(["pip", "freeze"], capture_output=True, text=True, check=True)
5052
return search_pip_freeze_output(project, r.stdout)
5153

@@ -220,7 +222,7 @@ def main() -> None:
220222
if info is None:
221223
print(f'Error: "{project}" is not installed', file=sys.stderr)
222224
print(file=sys.stderr)
223-
print(f'Suggestion: Run "python3 -m pip install {project}" and try again', file=sys.stderr)
225+
print(f"Suggestion: Run `{sys.executable} -m pip install {project}` and try again", file=sys.stderr)
224226
sys.exit(1)
225227
project, version = info
226228

scripts/install_all_third_party_dependencies.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
from ts_utils.requirements import get_external_stub_requirements
55

6-
use_uv = "--uv" in sys.argv
7-
if use_uv:
8-
pip_command = ["uv", "pip", "install"]
9-
else:
10-
pip_command = ["pip", "install"]
11-
12-
requirements = get_external_stub_requirements()
13-
subprocess.check_call(pip_command + [str(requirement) for requirement in requirements])
6+
7+
def main() -> None:
8+
requirements = get_external_stub_requirements()
9+
# By forwarding arguments, we naturally allow non-venv (system installs)
10+
# by letting the script's user follow uv's own helpful hint of passing the `--system` flag.
11+
subprocess.check_call(["uv", "pip", "install", *sys.argv[1:], *[str(requirement) for requirement in requirements]])
12+
13+
14+
if __name__ == "__main__":
15+
main()

tests/mypy_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def setup_virtual_environments(distributions: dict[str, PackageDependencies], ar
507507
print(colored(f"took {venv_elapsed_time:.2f} seconds", "blue"))
508508

509509
# STAGE 3: For each {virtual_environment: requirements_set} pairing,
510-
# `pip install` the requirements set into the virtual environment
510+
# `uv pip install` the requirements set into the virtual environment
511511
pip_start_time = time.perf_counter()
512512

513513
# Limit workers to 10 at a time, since this makes network requests

tests/runtests.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,12 @@ def main() -> None:
124124
print("\nRunning pytype...")
125125
pytype_result = subprocess.run([sys.executable, "tests/pytype_test.py", path])
126126
else:
127-
print(colored("\nSkipping pytype on Windows. You need to install it first: `pip install pytype`.", "yellow"))
127+
print(
128+
colored(
129+
f"\nSkipping pytype on Windows. You need to install it first: `{sys.executable} -m pip install pytype` .",
130+
"yellow",
131+
)
132+
)
128133

129134
cases_path = test_cases_path(stub if folder == "stubs" else "stdlib")
130135
if not cases_path.exists():

0 commit comments

Comments
 (0)