-
Notifications
You must be signed in to change notification settings - Fork 733
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
Installed package versions depend upon argument order in uv pip install #5474
Comments
I think this is reasonable. There are many equally-valid resolutions given that set of constraints, and so we have to prioritize packages in some order when solving. Modulo everything else, we prioritize in the order in which they were provided by the user. So, notice that in the first resolution, you have a newer The following would not be ok though:
But otherwise, I think this is ok. If one of the two outputs is desired, it should be encoded in the dependency constraints (e.g., |
The difference between the two results above as I see it is that |
Yes, that's possible and would be correct behavior. There's a good chance that pip would do exactly the same thing. |
We can't invent constraints that don't exist. Who knows, the inverse order could be equally problematic. |
So far pip has done the same thing consistently on the test cases I have tried, but maybe I just have not found the proper corner case. |
As a dependency resolution algorithm, we need to trust the packages that their metadata is correct (with the escape hatches of constraints and overrides), so when a package adds a new constraint, we have to assume that the new release has become incompatible. When a package does not provide upper bounds, we have to assume it's compatible with all versions, we have no means to figure out the actual bound in uv.
While this is possible algorithmically, it would be prohibitively expensive in uv's case. The by far slowest part is fetching metadata (even when we just read it from the cache), so we make the decision which package to prioritize without metadata. Another aspect is that the number of dependencies can change between releases, so we'd need to come up with a reliable, robust topological prioritization. Our current rules are using tighter specifiers first ( |
I recently had a quite confusing problem related to this. I don't think I understand why the resolver installs the version it does. requirements.txt: sphinx
sphinx_rtd_theme environment:
requirements.txt: sphinx_rtd_theme
sphinx environment:
I guess I can omit listing Does anybody know what |
We have From a pubgrub perspective, this is an interesting problem: Pubgrub works so that we first select a package, and then try all versions for that package. That means that we select either sphinx or sphinx-rtd-theme before we know that there is a sphinx-rtd-theme -> sphinx dep we want to consider. What we'd need to do to generate the desirable solution and this and the original case is: We have picked sphinx, and we have found a compatible version of sphinx. We next select sphinx-rtd-theme, and try the first version of sphinx-rtd-theme. We see a dep onto |
Discussion welcome to continue here — just closing as I've documented this now. |
Hi, I noticed when installing a package that the versions installed using
uv pip install
depends upon the order of the packages given to uv whereas when using pip the versions installed are consistent. For instance runninguv pip install importlib_metadata pysnyk
produces the following environment:Whereas if you run
uv pip install pysnyk importlib_metadata
you get the following environment:Pip seems to always produce the last result no matter the order of the packages, and from reading the docs I would expect
uv pip install
to produce the same result as pip here consistently?The examples above were produced with python3.11 and uv 0.2.29.
The text was updated successfully, but these errors were encountered: