-
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 20.2.4 with 2020 resolver does not use pinned version in the constraints file #9020
Comments
|
I do not understand how constraints are used with the new resolver. Can you give an example? |
They are basically a set of version specifications like
The difference isn't so much in how they are specified (except that the new resolver doesn't accept more complicated requirement syntax like extras or markers in constraint files) as in how they are used. In the old resolver, they were essentially treated as another set of requirements, but they didn't trigger an install unless there was a "non-constraint" requirement for that package as well. In the new resolver, constraints are applied much earlier, as part of finding candidates to feed into the resolver, so that the resolver never even sees candidates that don't match the constraints (which IMO is much closer in behaviour to what I think "constraint" means). The new resolver also doesn't see the constraints, as they have been applied before the resolver gets involved. The consequence here is that the resolver never sees a requirement The problem is that hash-checking mode requires that all requirements are specified as a |
The reason I say "I don't know how we'd fix this" is because I think the issue is in hash-checking mode, which shouldn't be checking for explicit |
This question is an easy one to answer, it is from Django: The other one is harder, I'd have to get into the new resolver code. I'm guessing that the hash will have to get attached to the version earlier in the process. A requirement of |
I captured the verbose output of https://gist.github.com/jwhitlock/c09714f7df4557333a38591ac1b642bf#file-output-txt-L1196
My reading of this is that filter_unallowed_hashes knows that it needs to check hashes, and successfully filters by one with the given hashes. That gives me more hope that the hashes can be available on the |
I modified the title to reflect my observation to the issue. The error message indicates that hashes are not the issue, but the resolver not “using” the With the current implementation, the user is expected to |
I'd consider it a regression if this case wasn't handled by the 2020 resolver. But, it could be an intentional regression. Those of us that need to use hashes would avoid constraints, and use tools like It would probably require a note in the docs for both constraints and hashes to say that the two shouldn't be used together. |
I just spoke with @pradyunsg and we confirmed that the docs update in https://pip.pypa.io/en/latest/user_guide/#watch-out-for within https://pip.pypa.io/en/latest/user_guide/#changes-to-the-pip-dependency-resolver-in-20-3-2020 serves to resolve this issue. Thank you for the bug report and for working through it with us! |
Got here from #9243. It seems weird to suddenly expect that, when a constraints file specifies a version pin and a hash, the resolver would ignore the hash completely when requirements doesn't specify it. That seems to make constraints files essentially useless, because now for anyone using require-hashes, it makes no sense to specify the dependency in both requirements.txt and constraints.txt, and it also doesn't make sense to go through repeated installs and find every subdep specified with a range and special-casing those for requirements.txt. Is there some reasoning someone can point to for breaking this flow? |
I am using
As of pip 21, I get this error on CI:
in the collectfast
I'm guessing that the resolver is not recognizing Edit: removing the
Not a catastrophic work-around, but I'd prefer to avoid the extra install if I could. |
We ran into this as well and came up with the same solution. Is there any open issue to tackle this specific situation? |
If you're using the resolver on a fully pinned package set, you can use --no-deps to avoid it doing pedantic dependency resolution. |
Great, I can confirm this fixes our problem. Thanks a million! |
The implementation-related fix is being tracked in #9243. |
What did you want to do?
Consider this
requirements.txt
:Django 3.1 has three dependencies, listed with hashes in
constraints.txt
:With pip 20.2.4, this installs the four packages:
Using the 2020 resolver fails:
It also fails with the in-development version of pip.
Output
Working output:
Failed output:
The dependency that causes the error can vary from call to call.
Additional information
Here's the output of
pipdeptree
for the successful case:This was first reported in issue #8792, which is marked as fixed in pip 20.2.4 with PR #8839.
A working demo is at https://github.com/jwhitlock/pip-resolver-demo. I've simplified it to this example since it was first written.
The text was updated successfully, but these errors were encountered: