-
Notifications
You must be signed in to change notification settings - Fork 137
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 + in wheel filenames #388
Conversation
To be clear, this is not a problem for released versions (which must not have the local identifier to be uploaded to pypi), but it is affecting my CI systems. |
ping @takluyver |
@takluyver can you please appoint additional maintainers? Flit is used by many people and it would make sense to have a faster response time to bugs like this. |
I believe that pip and setuptools are going against the spec here, because that regex comes directly from the spec, specifically PEP 427, which also says
It may be that we end up changing the spec and fixing Flit rather than fixing setuptools or pip. But I'd like to check that with the pip maintainers. |
I have opened an issue on pip to discuss this: pypa/pip#9628 |
OK! See https://discuss.python.org/t/escaping-versions-for-wheel-sdist-and-dist-info-names/5605/19:
So we should either go ahead with the change in this PR or switch to one of the suggested alternatives. |
Thanks! We're already normalising the version number (search for Do you have a workaround for the time being? I'd prefer to wait until a change to the spec is accepted before doing a new release, to avoid having an intermediate state that might not fit with either the old or new version of the spec. |
What @uranusjr meant is that the version part of the wheel filename should be the normalized version without any additional mangling. Therefore this PR should help already. |
return '{}-{}-{}.whl'.format( | ||
re.sub(r"[^\w\d.]+", "_", self.metadata.name, flags=re.UNICODE), | ||
re.sub(r"[^\w\d.]+", "_", self.metadata.version, flags=re.UNICODE), | ||
re.sub(r"[^\w\d\+.]+", "_", self.metadata.version, flags=re.UNICODE), | ||
tag) |
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.
In compliance with the recently changed spec, this should be the correct:
return '{}-{}-{}.whl'.format( | |
re.sub(r"[^\w\d.]+", "_", self.metadata.name, flags=re.UNICODE), | |
re.sub(r"[^\w\d.]+", "_", self.metadata.version, flags=re.UNICODE), | |
re.sub(r"[^\w\d\+.]+", "_", self.metadata.version, flags=re.UNICODE), | |
tag) | |
# See https://packaging.python.org/specifications/binary-distribution-format/#escaping-and-unicode | |
assert '-' not in self.metadata.version, 'Normalized versions can’t have dashes' | |
return '{}-{}-{}.whl'.format( | |
re.sub(r"[-_.]+", "_", self.metadata.name, flags=re.UNICODE), | |
self.metadata.version, | |
tag) |
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.
Where does self.metadata.version
come from? Dashes are allowed in Core metadata (the field used in the {name}-{version}.dist-info/METADATA
file), so the assertion may not be correct depending on how Flit implements this.
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.
Metadata
is created via
where get_info_from_module
does
and check_version
calls
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.
I think @flying-sheep's suggestion is correct - so long as our implementation of version normalisation is correct (and I've read PEP 440 correctly!), there should be no dashes in version
.
I'd also like to check when constructing the filename that the compatibility tag has exactly two dashes ({python tag}-{abi tag}-{platform tag}
), to avoid any nasty surprises. But that check can be added later.
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.
Assuming Flit only accepts PEP 440 versions, the normalisation logic should be identical in both places, yes. |
That's a good point. Flit can allow non-pep-440 version numbers with |
Well, let’s get something released that works at all, then we can address deprecated corner cases whenever? |
The latest releases of pip (released today, v20.3.4 and v21.0) add a verification step which checks the info in the generated filename against the package. (pypa/pip#9320, specifically these lines)
This caused versions with extra info (e.g. git branch) appended to the version using
+
to fail the check, since flit replaces all non alphanumeric characters with_
in the filename (the actual metadata still has the plus sign, but the check is against the filename).I checked against behavior of setuptools, which retains
+
in the filename of the wheel.This simply allows the
+
character in the version part of the filename (I believe it is not allowed in the package name itself)As to whether a filename with an
_
in place of+
should fail such a verification, I'm not totally convinced, but it is easy enough to allow the character.