-
Notifications
You must be signed in to change notification settings - Fork 252
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
Follow most recent packaging specification for wheel name normalization #394
Follow most recent packaging specification for wheel name normalization #394
Conversation
As per https://packaging.python.org/en/latest/specifications/binary-distribution-format/#binary-distribution-format, the specification replaces the original PEP 427 specification. The specification for the distribution name is https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode.
Keeping this as a draft for now, since I'm not entirely sure about the implications of changing the logic here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me as this only affects generated artifacts (bdists) and the spec explicitly calls out that tools must continue to support wheel names generated using the old logic -- given this is a subset of possible names before the spec update, it should be fully compatible. Still, going to wait for @abn to concur.
As this is only affecting generated bdist files, I agree with @neersighted. However (outside the scope of this PR), I am now curious if we do the right thing in cases where PEP 503 normalisation does not match wheel name escapes - ie. how do we tell if |
Thanks to both of you for confirming that. I also think that since this only touches the generation of the wheel name (not it's retrieval locally nor on a distant remote, AFAIK), we should be safe here.
That's a valid concern. I can take a look at what we currently do later on, since the normalisation of wheel names may occur in various different situations (local cache, distant remote, etc.), so definitely worth a look. |
@@ -29,5 +29,5 @@ def escape_version(version: str) -> str: | |||
|
|||
|
|||
def escape_name(name: str) -> str: | |||
"""Escaped wheel name as specified in :pep:`427#escaping-and-unicode`.""" | |||
return re.sub(r"[^\w\d.]+", "_", name, flags=re.UNICODE) | |||
"""Escaped wheel name as specified in https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe expand this doc string to indicate that this should only be used for generation of wheels never to canonicalize artifact package names.
ed7078e
to
0651747
Compare
Co-authored-by: Bjorn Neergaard <bjorn@neersighted.com>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
…on (python-poetry#394) * test(masonry): add tests for `escape_*` methods * feat(masonry): follow newer PyPA specification for wheel name As per https://packaging.python.org/en/latest/specifications/binary-distribution-format/#binary-distribution-format, the specification replaces the original PEP 427 specification. The specification for the distribution name is https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode. * refactor(masonry): indicate that `escape_name` is for generated wheels only * doc(masonry): improve `escape_name` documentation Co-authored-by: Bjorn Neergaard <bjorn@neersighted.com>
Highlighted by python-poetry/poetry#5782 and looking into PyPA packaging specification that supersedes PEP 427:
So it looks like the regex we use to escape wheel name should be updated to what PEP 503 defines, with the minor change of using
_
for the replacement character instead of-
.