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

Should uv sync remove extraneous packages? #4358

Closed
ibraheemdev opened this issue Jun 17, 2024 · 8 comments
Closed

Should uv sync remove extraneous packages? #4358

ibraheemdev opened this issue Jun 17, 2024 · 8 comments
Assignees

Comments

@ibraheemdev
Copy link
Member

It currently does not, while uv pip sync does. This would also affect whether uv remove removes all extraneous packages, or has to do extra work to only remove the affected packages.

@zanieb
Copy link
Member

zanieb commented Jun 17, 2024

In brief, I think we should:

  1. Change sync to always remove extraneous packages. This is the common understanding on sync.
  2. Implement an opt-out option for removal during sync, e.g. --allow-extra-packages
  3. Update uv remove to allow extraneous packages by default, only removing the relevant dependency tree

@zanieb zanieb added the preview Experimental behavior label Jun 17, 2024
@ibraheemdev ibraheemdev self-assigned this Jun 17, 2024
ibraheemdev added a commit that referenced this issue Jun 17, 2024
## Summary

First step of #4358. `uv sync`
will now remove any extraneous installations by default.
@ibraheemdev
Copy link
Member Author

uv sync now removes extraneous packages by default, which you can opt-out with --no-clean.

Currently uv add and uv run do not ever remove from the environment, and so uv remove should, for consistency, only remove the affected packages. An alternative approach to 3 is to have all project commands, uv run, uv add, and uv remove, always clean the virtual environment, which would simplify things and doesn't seem necessarily problematic.

@zanieb
Copy link
Member

zanieb commented Jun 19, 2024

I don't think they should always clean the virtual environment. I think it's too common for people to manually manage packages in Python and without an explicit sync it seems excessive for us to purge extraneous packages. Changing remove to be more clearly scoped by default seems like a more intuitive user experience.

@charliermarsh
Copy link
Member

Update uv remove to allow extraneous packages by default, only removing the relevant dependency tree

Does this mean: uv remove foo uninstalls foo, or uninstalls foo and its dependencies?

@charliermarsh
Copy link
Member

My current vote is that it uses the same semantics as uv run, and we add an --exact argument to enable exact syncing. But I would also be okay shipping with the current behavior.

@zanieb zanieb removed the preview Experimental behavior label Aug 20, 2024
@T-256
Copy link
Contributor

T-256 commented Sep 19, 2024

I think it's too common for people to manually manage packages in Python and without an explicit sync it seems excessive for us to purge extraneous packages.

IIUC, uv's top level commands do some automations to keep your workspace in sync between lockfile, pyproject.toml and venv.
I think who wants manually manage packages could use low level commands, i.e. uv pip uninstall in this case.

@zanieb
Copy link
Member

zanieb commented Sep 19, 2024

I think we made a decision on this — we have a toggle now.

@aberres
Copy link

aberres commented Oct 11, 2024

For anyone coming here after not finding the switch when looking at --help: It is called --inexact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

No branches or pull requests

5 participants