-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Pip fails to install some satisfiable requirements since extras optimization #12376
Comments
I can not try for myself right now but this looks to me like the same root cause as #12372 (comment). I already have a potential fix to it (linked in that discussion). |
I don't think so, which is why I didn't add this example to that issue. And testing your branch I get the same error:
|
I also tried the approach of That said I haven't been able to reproduce the error without using a local extra, so it could be the same root cause, but my beleif is just this is because I'm unable to successfully extract the same top level requirements Pip has collected in the order Pip has collected them (it would be great it Pip had a command for that #12185 !) |
Confirmed, it's not related to local extras install, can reproduce it by attempting to install from PyPI like so (no need to clone repo):
Which works on Pip 23.2.1 but fails on Pip 23.3.x with:
Also fails installing pip from |
I tried debugging this a bit today, I think my hypothesis about the optimization being applied when the extra is invalid is not correct, adding some debug statements the optimization did only appear to being applied for valid extras. Sorry I couldn't be of further help, if I think of something else I will investigate. |
I looked into this for some time and I think I understand more or less what's going on. First, this package has a huge and complicated dependency tree with many upper bounds, resulting in complicated resolution process. The dependency conflict seems to be an interplay between constraints on I am relatively confident that the root cause is that resolvelib can not reliably do the proper backtracking required to come to a satisfactory solution. That said, the specific case that resolvelib has trouble with used to be one that would only arise when dependencies with and without extra are present for the same package. Pip now inserts those itself, meaning that this behavior is triggered more easily. So it should probably be addressed. Some more details, and a smaller reproduction follow below. If you strip everything but the dependencies on On pip 23.2.1, if you add #12095 made an attempt to couple extra and extra-less dependencies more tightly. However, it still has some limitations. One of them is that To be clear: I believe the only part of #12095 that really affects this regression is the injection of the implicit extra-less dependency. The rest of the pull request (tighter coupling of extra and extra-less dependencies) is unrelated as far as I can see. I do not have a solution in mind yet. There are still some details that are not entirely clear to me. Perhaps some changes to the |
Interesting, I do wonder then if this is still an issue with backjumping but doesn't cause the specific exception that happens in the other issue. I am interested if reverting the backjumping optimization the issue will still happen, when I get some free time I will try implementing that and see if it successfully resolved or still produces an error. |
Interesting analysis. It's unfortunate that resolvelib needs these contortions to support extras - the problem is it's necessary because, while we can handle dependencies being costly to compute (and so, we calculate them on demand) we do still rely on them being constant once computed - and extras break that assumption if we take the project name/version alone as defining the candidate. I'm not sure my observation here is particularly helpful, as I doubt we can modify something as fundamental as this, but maybe it'll suggest something 🤷 |
I created a branch which reverted out the backjump optimization and for me this now resolves: notatallshaw/pip@main...remove-backjump @sanderr when you get a chance would you mind testing this branch with your examples you give in your comment: https://github.com/notatallshaw/pip/tree/remove-backjump I'm now of the opinion this is a correctness issue with the backjump optimization added to resolvelib, and not with the extras optimization added to Pip. And unless anyone objects we can mark this a duplicate of #12317. I'm going to add a comment to sarugaku/resolvelib#134 and spend a little time seeing if I can spot where the backjump is incorrectly skipping over a correct state.
A note on this, my understanding is |
Indeed, with that branch I can no longer reproduce the issue. |
Okay, to finally round this out, I remembered there was another set of requirements (tested on Python 3.8 Linux) that failed to installed prior to the extas optimization but installed after it: I created another branch to test with the extras optimization removed: notatallshaw/pip@main...no-extras-optimization If I test this I get:
IMO then the extras optimization alters what requirements surface the correctness issue in resolvelib (seemingly caused by the backjumping optimization), but does not necessarily even make it more likely, and the work to fix this should be on the resolvelib side. Ultimately it's up to Pip maintainers, but I am going to close this in favor of #12317 |
Thanks @notatallshaw for the investigations here! They're appreciated! :) |
FWIW, I think it can also be an inaccuracy in how the extras optimisation works. |
I don't disagree it's possible, but to summarize what we've found so far:
So IMO given this, and debugging work done, I don't think it's valid to point the finger at extras optimization unless something new is found |
Description
In Pip 23.3, an extras optimization was introduced to improve the speed of backtracking when dealing with extras. However, under specific circumstances, this optimization can lead to Pip failing to install valid requirements.
In PR kedro-org/kedro#3182 it linked to a Pip issue #12317 as a cause of resolution failure, but investigating I found:
To further investigate I tested various Pip branches, and I believe the problem arises when the following warning is encountered:
I hypothesize that the optimization is being applied when no extra actually exists. This occurs because extras are optional, and Pip will simply emit a warning when an extra is not present.
Expected behavior
Optimization should not cause failure
pip version
pip 23.3.1
Python version
3.11
OS
Linux
How to Reproduce
Output
Code of Conduct
The text was updated successfully, but these errors were encountered: