Skip to content

Don't explicitly install Python. Use uv sync instead of uv add. #540

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 4 commits into from
Feb 19, 2025

Conversation

tdhopper
Copy link
Contributor

Thanks for writing up the uv instructions. Here are some tweaks on using uv idiomatically.


```bash
uv python install 3.10
uv sync --dev --python 3.11
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for the PR! Question: Doesn't uv sync remove packages that are not explicitely defined as dependencies in the pyproject.toml though? Sure, in some cases that's maybe what you want, but I can also see where this is annoying if you

  1. setup up your new venv, install a bunch of packages
  2. then run uv sync on the pyrpoject.toml and discover those are then gone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's correct.

My read of this instructions was that they're for setting up the project environment for the first time (it doesn't, for example, include instructions on setting up a venv).

If you want to prevent that, you can do uv sync --inexact.

But beyond that, if you're using pyproject.toml to management dependencies, it's an antipattern to add dependencies to the environment that you're not tracking in the pyproject.toml. uv add and uv pip install shouldn't be used together.

One last point, uv sync is going to explicitly tell you if it installs packages, so it should at least be clear to end users what is going on.

@rasbt
Copy link
Owner

rasbt commented Feb 19, 2025

My read of this instructions was that they're for setting up the project environment for the first time (it doesn't, for example, include instructions on setting up a venv).

That's fair, and I like your changes overall. Thanks for taking the time to do this PR!

@rasbt rasbt merged commit 1039bf9 into rasbt:main Feb 19, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants