Allow URL constraints to apply to requirements with extras#13886
Open
Allow URL constraints to apply to requirements with extras#13886
Conversation
Combining a URL-pinned constraint with a requirement that requests extras -- e.g. pinning `pandas` to a wheel URL while installing `pandas[performance]` -- used to crash the resolver with `AssertionError: 'pandas[performance]' != 'pandas' for wheel`. Constraints are keyed by base name, and `_get_with_identifier` intentionally falls back from `pkg[extra]` to `pkg` so that version/hash constraints don't need to be restated per extras combination. That fallback works well for specifier/hash data, but a constraint's link carries identity -- it *is* `pkg`, not `pkg[extra]` -- and flowing it into `_iter_candidates_from_constraints` under the extras-bearing identifier falls over because there's no handling of extras in it. Extracting the extras from the identifier (similar to how `_iter_explicit_candidates_from_base` already adapts regular requirements) and wrapping it in an `ExtrasCandidate` corrects the mismatch, handling the extras & constraints appropriately.
10990d0 to
0656b71
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12018
Closes #12025 which it supercedes
I blame @ichard26 for making to me stare at this too long by asking me to review what kinda effort it would take to tackle https://github.com/pypa/pip/milestone/47.
Also, shoutout to @harupy for filing such a clear bug report -- I was able to recreate it even a few years down the line (with newer wheel & Python versions), and that was helped immensely by the fact that your report was clear, concise and to the point. It is appreciated! ^.^