-
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
Implement PEP 685 extra normalization in resolver #12002
Conversation
All extras from user input or dependant package metadata are properly normalized for comparison and resolution. This ensures requests for extras from a dependant can always correctly find the normalized extra in the dependency, even if the requested extra name is not normalized. Note that this still relies on the declaration of extra names in the dependency's package metadata to be properly normalized when the package is built, since correct comparison between an extra name's normalized and non-normalized forms requires change to the metadata parsing logic, which is only available in packaging 22.0 and up, which pip does not use at the moment.
Yea, this fails to handle packages that don't pull in PEP 685 style extra names. :/ |
Note to self it’d be a good idea to also provide a better error message for this. |
Alright, addressed the test failure. In fact I re-implemented this almost entirely, so now the resolver actually keeps track of non-normalized (requested) extras alongside with the normalized form. The normalized form is used in the resolver, except when a candidate inspects distribution metadata to look for dependencies—both the normalized and non-normalized forms are used for look up. This means that if a package is built without following PEP 685, the user (and the package’s dependants) can still access the extra using the non-normalized form. And once we upgrade to newer The only failing scenario now would be if a distribution is built without normalizing extras, and is requested with a normalized extra. This would not have worked prior to PEP 685 anyway, and will continue to fail until we upgrade |
When an unnormalized extra is requested, try to look up dependencies with both its raw and normalized forms, to maintain compatibility when an extra is both specified and requested in a non-standard form.
76335ad
to
d64190c
Compare
Since this function now always take normalized names, additional normalization is no longer needed.
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
f271535
to
99bea32
Compare
Gosh this setuptools thing is so annoying. I think I’ll try to manually build a package instead 😐 |
Should be feasible with |
This removes extra normalization when metadata is loaded into the data structures, so we can obtain the raw values later in the process during resolution. The change in match_markers is needed because this is relied on by the legacy resolver. Since we removed eager normalization, we need to do that when the extras are used instead to maintain compatibility.
c525928
to
15a3ba5
Compare
The importlib.metadata and pkg_resources backends unfortunately normalize extras differently, and we don't really want to continue using the latter's logic (being partially lossy while still not compliant to standards), so we add a new abstraction for the purpose.
15a3ba5
to
9ba2bb9
Compare
i have a side channel question for this one wrt implementing certain helpers on top of this for normalizing extras of specific versions to a canonical extra (to support default extras) how hard would it be to expand the resolver to turn extras from a intermediate for to something like "canonical" extras when the solver picks a specific version (in my wip draft for the pep intend to turn extras like if its not unreasonably hard to implement/put on top, i'd go forward with making my draft publishable |
Shouldn’t be too hard. The point of this is actually to delay marker normalisation as much as possible, and not at all once |
All extras from user input or dependant package metadata are properly normalized for comparison and resolution. This ensures requests for extras from a dependant can always correctly find the normalized extra in the dependency, even if the requested extra name is not normalized.
Note that this still relies on the declaration of extra names in the dependency's package metadata to be properly normalized when the package is built, since correct comparison between an extra name's normalized and non-normalized forms requires change to the metadata parsing logic, which is only available in packaging 22.0 and up, which pip does not use at the moment.
Close #11649 (but not #11445!)