Skip to content
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

Update pip install calls in scripts to use uv or reference current executable #13597

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Mar 7, 2025

This forces working with a virtual environment for those scripts, but it doesn't force a name on your venv (uv pip and uv run --active will reuse your activated environment)

Note I didn't touch python/python3 --> uv run in this PR. (that's done in #13599)
I'm also leaving GitHub jobs to a separate self-contained PR.

I changed lists to tuples on relevant lines.

@Avasam Avasam added the project: infrastructure typeshed build, test, documentation, or distribution related label Mar 7, 2025
CONTRIBUTING.md Outdated
replacing `$INSERT_LIBRARY_NAME_HERE` with the name of the library:

```bash
(.venv)$ pip install $INSERT_LIBRARY_NAME_HERE
(.venv)$ uv pip install $INSERT_LIBRARY_NAME_HERE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think contributors shouldn't need to know about uv. While I'm fine with using uv to speed up our CI, it's not something I would personally use when developing locally, and I don't think it solves a problem for the typical contributor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do use uv all the time locally, but I'd also much prefer it if new contributors don't have to worry about it. I really want new contributors to be able to get up and running as quickly as possible on typeshed; the setup steps should be as simple as possible and involve the bare minimum of custom tools IMO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've only changed places where I'd assume pip install -r requirements-tests.txt was already run.

Using it in doc was less about install speed, and more about not having to worry about virtual environments, and whether it exists / is activated.

I could see being told to run a custom tool (uv) when you may not even know that it was part of the installed requirements to be jarring.
I've updated the PR with that in mind.

@Avasam Avasam changed the title Use uv pip in scripts and docs Update pip install calls in scripts to use uv or reference current executable Mar 9, 2025

def main() -> None:
requirements = get_external_stub_requirements()
subprocess.check_call(("uv", "pip", "install", *sys.argv[1:], *[str(requirement) for requirement in requirements]))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By forwarding arguments, we naturally allow non-venv (system installs) by letting the script's user follow uv's own helpful hint:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: infrastructure typeshed build, test, documentation, or distribution related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants