Skip to content
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

Allow legacy version in wheel metadata #9199

Closed

Conversation

uranusjr
Copy link
Member

@uranusjr uranusjr commented Dec 2, 2020

Fix #9188.

I took a look at the code that crashed and realised it was only performing a sanity check (and is arguably not even necessary if you walk through all the code paths that go through it). Although it’s likely a good idea to start requiring PEP 440 versions for wheels, IMO it should not be done in this part, but when the wheel is actually downloaded.

This PR simply makes the check more lax to pass the sanity check. I’ll open another issue to work on logic to implement PEP 440 enforcement if it is accepted as a good idea.

@uranusjr
Copy link
Member Author

uranusjr commented Dec 2, 2020

The PEP 440 check should be done here instead:

def _check_metadata_consistency(self, dist):
# type: (Distribution) -> None
"""Check for consistency of project name and version of dist."""
# TODO: (Longer term) Rather than abort, reject this candidate
# and backtrack. This would need resolvelib support.
name = canonicalize_name(dist.project_name)
if self._name is not None and self._name != name:
raise MetadataInconsistent(self._ireq, "name", dist.project_name)
version = dist.parsed_version
if self._version is not None and self._version != version:
raise MetadataInconsistent(self._ireq, "version", dist.version)

@pradyunsg
Copy link
Member

pradyunsg commented Dec 3, 2020

Although it’s likely a good idea to start requiring PEP 440 versions for wheels, IMO it should not be done in this part, but when the wheel is actually downloaded.

This PR simply makes the check more lax to pass the sanity check.

Agreed, and on board. :3

I’ll open another issue to work on logic to implement PEP 440 enforcement if it is accepted as a good idea.

From a change management perspective: we've already "broken" users who want the lax/no PEP 440 enforcement, so it'd be better overall to also (re-)implement the PEP 440 strictness w/ better error messaging in the same bugfix release, so we're not flip-flopping on this issue. It has already eaten into our churn budget, so... might as well not pay the churn cost again?

In other words, yes I like the idea, and (puts on RM hat) that change either blocks the merge of this PR or you can include it here (takes off hat).

@uranusjr
Copy link
Member Author

uranusjr commented Dec 3, 2020

PR updated. Let’s use #9206 to track the deprecation warning addition.

@pradyunsg pradyunsg added state: blocked Can not be done until something else is done type: enhancement Improvements to functionality labels Dec 3, 2020
@uranusjr uranusjr removed the state: blocked Can not be done until something else is done label Jan 7, 2021
@uranusjr
Copy link
Member Author

uranusjr commented Jan 7, 2021

This should be ready now #9320 is merged (closing #9206).

@BrownTruck
Copy link
Contributor

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 master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Feb 20, 2021
@uranusjr uranusjr force-pushed the new-resolver-wheel-version-catch branch from d19134b to 6b565a6 Compare February 22, 2021 17:23
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Feb 22, 2021
pradyunsg
pradyunsg previously approved these changes Feb 22, 2021
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man, I've forgotten all the context around this, but the change does what it says in the title. :)

@pradyunsg
Copy link
Member

Wait, if we're enforcing that built wheels follow PEP 440, why do we want to relax pip install now? Especially because packaging is going to be dropping LegacyVersion soon anyway.

@pradyunsg pradyunsg dismissed their stale review February 22, 2021 17:40

See comment above.

@pradyunsg
Copy link
Member

Yea, re-reading the issue, I think what we have to do now is improve the error message and to not permit legacy versions in wheels.

@uranusjr
Copy link
Member Author

Technically wheels can use non-PEP-440 version, if the .dist-info it contains uses Metadata 1.0. But we don’t know a wheel’s metadata version just by looking at its filename, so we allow it here. A later check during prepare() will make sure that wheel is actually using Metadata 1.0, and complain if not (and skip the wheel altogether). This makes the check more technically correct (to avoid possible spec police complaining PEP 427 doesn’t actually enforce PEP 440), and also allows us to emit a more accurate error message to the actual issue (which is the more important benefit to me).

@uranusjr
Copy link
Member Author

Although, after checking, it seems like we haven’t applied the verification to downloaded wheels (only built wheels now), so that should happen first.

@uranusjr uranusjr added the state: blocked Can not be done until something else is done label Feb 22, 2021
@pfmoore
Copy link
Member

pfmoore commented Feb 22, 2021

I've also lost any context on this, but honestly, I think we should be enforcing newer standards. I'm fine with saying that the current behaviour was an unintentionally abrupt deprecation (🙂) and "fix" it by allowing it again for a version or two with a deprecation warning, but given that when support for legacy versions is removed is out of our hands because we rely on packaging, I'm also fine with just saying sorry, consider the deprecation of the old resolver as the deprecation period for this as well.

As a broader point, maybe we should make a "statement of direction" in the docs that explicitly confirms that pip (along with the wider packaging ecosystem) is moving towards stricter enforcement of up to date published standards, and as a consequence we will be gradually removing support for "legacy" behaviours. Users who currently rely on legacy behaviours should actively look at updating to follow current standards, and if they decide not to (or can't) must be prepared at some point to pin their version of pip, and understand that they won't be able to take advantage of improvements to pip after that point.

(It probably won't make much practical difference, as people will either not read the note, or assume their usage is OK, or otherwise not do anything about it. But at least we will have done our part by publicising our intent.)

@BrownTruck
Copy link
Contributor

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 master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Mar 23, 2021
@pradyunsg
Copy link
Member

It's been long enough that I don't think we need to do this.

In any case, this PR needs updating anyway; so if there's any interest in this still, the interested folks can file a new PR to move this forward. :)

@pradyunsg pradyunsg closed this Sep 18, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2021
@uranusjr uranusjr deleted the new-resolver-wheel-version-catch branch December 4, 2021 13:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs rebase or merge PR has conflicts with current master state: blocked Can not be done until something else is done type: enhancement Improvements to functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message for wheels with non-compliant versions
5 participants