Open nikhilweee opened 2 months ago
The discussion at https://github.com/astral-sh/uv/issues/4730 may be helpful
Thanks for the pointer @zanieb, I think the following comment comes close to capturing the gist of this issue.
https://github.com/astral-sh/uv/issues/4730#issuecomment-2203338364
The huge drawback here: Modulo default-{packages,extras,command}, you have to specify all arguments in every uv run every time.
I'd also like to add that remembering lockfile options would make it easy for users switching from other package managers.
To clarify one thing, the extras have no impact on the lockfile -- we lock for all extras at once. uv lock
doesn't even accept extras as an argument :) The extras only impact the installation phase (which subset of packages should we install), not the locking phase (which packages should we include when resolving). This is different from Rye which can't produce a lockfile that supports switching out extras at install-time, so has to encode them like that.
Ah, sorry my understanding of uv internals is not the best. That said, the spirit of this issue is to remember previous lock options when running uv install
. If this is something of interest, I'm sure the implementation details can be discussed further.
Problem Description
uv sync
, by itself, does not install optional dependencies. Which is fine, I believe it's how it should be.But let's say I am running
uv sync
for the first time. I wish to include two extras,extra1
andextra2
. I run the following:Great. Now I have the package with extras installed. But what about subsequent syncs?
Suggestion
One argument is to remember the two extras (and other lock options) from before, and use them as the new defaults. In other words, subsequent syncs should imply
--extra extra1 --extra extra2
. If an extra argument is provided explicitly during sync, these new extras should override the defaults. I believe this is how it currently works inrye
andpdm
. Those tools store lock options in their lockfiles.The PDM lockfile has a metadata section which stores these implicit extras
Similarly, Rye stores these implicit extras in its lockfile
AFAIK I don't think UV stores lock options in its lockfile. Should we think about remembering previous lock options?
Related
I am aware that that PEP-751 is under discussion and from a brief glance I'm not sure if package managers will be able to store any kind of metadata in there. That said, it's still a draft and maybe we can bring this up.