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.
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.
* Use strict optional checking in req_install.py
Suggested by pradyunsg in #11374
Since half of the API of this class depends on self.req not being None,
it seems like we should just prevent users from passing None here.
However, I wasn't able to make that change.
Rather than sprinkle asserts everywhere, I added "checked" properties.
I find this less ad hoc and easier to adapt if e.g. we're able to make
self.req never None in the future.
There are now some code paths where we have asserts that we didn't
before. I relied on other type hints in pip's code base to be accurate.
If that is not the case and we actually relied on some function being
able to accept None when not typed as such, we may hit these asserts.
But hopefully tests would catch such a thing.
* news
* black
* inline asserts
* code review
* fix up merge issue
* fix specifier bug
This more accurately reflects that it is not necessarily
related to original_link, original_link being the direct URL
link,
and the wheel cache can also be populated from sdists
URL discovered by the finder.
Before it did support only requirements that had their
metadata prepared to a local directory.
WIth wheels that does not happen so we need to
handle that case too.
get_dist() is used by the metadata property of InstallRequirement,
which in turn is useful to obtain metadata
of the RequirementSet returned by the resolver.
When there is a pyproject.toml, metadata preparation must be
done in the isolated build environment for legacy editable installs too
(fixes a regression).
Also detect earlier if an editable install must go through the
legacy install path, to be sure to run it in an environment
with the correct build requirements.