Skip to content

Allow URL constraints to apply to requirements with extras#13886

Open
pradyunsg wants to merge 1 commit intopypa:mainfrom
pradyunsg:resolver-constraints-extras
Open

Allow URL constraints to apply to requirements with extras#13886
pradyunsg wants to merge 1 commit intopypa:mainfrom
pradyunsg:resolver-constraints-extras

Conversation

@pradyunsg
Copy link
Copy Markdown
Member

@pradyunsg pradyunsg commented Apr 5, 2026

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! ^.^

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.
@pradyunsg pradyunsg force-pushed the resolver-constraints-extras branch from 10990d0 to 0656b71 Compare April 5, 2026 22:01
@pradyunsg pradyunsg marked this pull request as ready for review April 5, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AssertionError when installing a package with an extra and a URL constraint

1 participant