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
Namespace packages with dots in them fail to upload to PyPI #743
Comments
The breaking change appears to be 0bd26af#diff-30ee60b48548622c54dfa266e095021f403ad23ab4848c74b2deed5df329ae00R62 >>> import pkg_resources
>>> pkg_resources.safe_name("mosaik.SimConfig")
'mosaik.SimConfig'
>>> import packaging.utils
>>> packaging.utils.canonicalize_name("mosaik.SimConfig")
'mosaik-simconfig' |
Same problem here, just broke my build. Downgrading to 3.3.0 as a workaround solves the issue. |
@jaraco Are you able to look into this? |
In the meantime, if someone could open a PR with a failing test that reproduces this (maybe in test_package.py), it would be greatly appreciated. |
Commit 0bd26af introduced a regression that was causing some namespace packages with dots in them fail to upload to PyPI. The reason is because `packaging.utils.canonicalize_name()` is not equivalent to `pkg_resources.safe_name()` as the former transforms the "." into "-", while the later only does it for non-alphanumeric/. characters. Closes: pypa#743
Commit 0bd26af introduced a regression that was causing some namespace packages with dots in them fail to upload to PyPI. The reason is because `packaging.utils.canonicalize_name()` is not equivalent to `pkg_resources.safe_name()` as the former transforms the "." into "-", while the later only does it for non-alphanumeric/. characters. Closes: pypa#743
Commit 0bd26af introduced a regression that was causing some namespace packages with dots in them fail to upload to PyPI. The reason is because `packaging.utils.canonicalize_name()` is not equivalent to `pkg_resources.safe_name()` as the former transforms the "." into "-", while the later only does it for non-alphanumeric/. characters. Closes: pypa#743
Commit 0bd26af introduced a regression that was causing some namespace packages with dots in them fail to upload to PyPI. The reason is because `packaging.utils.canonicalize_name()` is not equivalent to `pkg_resources.safe_name()` as the former transforms the "." into "-", while the later only does it for non-alphanumeric/. characters. Closes: pypa#743
Commit 0bd26af introduced a regression that was causing some namespace packages with dots in them fail to upload to PyPI. The reason is because `packaging.utils.canonicalize_name()` is not equivalent to `pkg_resources.safe_name()` as the former transforms the "." into "-", while the later only does it for non-alphanumeric/. characters. Closes: pypa#743
Commit 0bd26af introduced a regression that was causing some namespace packages with dots in them fail to upload to PyPI. The reason is because `packaging.utils.canonicalize_name()` is not equivalent to `pkg_resources.safe_name()` as the former transforms the "." into "-", while the later only does it for non-alphanumeric/. characters. Closes: pypa#743
Commit 0bd26af introduced a regression that was causing some namespace packages with dots in them fail to upload to PyPI. The reason is because `packaging.utils.canonicalize_name()` is not equivalent to `pkg_resources.safe_name()` as the former transforms the "." into "-", while the later only does it for non-alphanumeric/. characters. Closes: pypa#743
Ah, I forgot that I cand easily DDoS an issue by mentioning the issue number in the commit message :)
Opened PR here: #745 |
Looks like PyPI wasn't ready for this change, since it also uses I guess a decent plan would be to merge #745, and then start allowing both canonical / safe_name on warehouse's end point and then revert #745. |
It's clear that |
I'm pretty sure we want to get to the point where we're using |
I agree that 0bd26af#diff-30ee60b48548622c54dfa266e095021f403ad23ab4848c74b2deed5df329ae00L61-R62 is an invalid change. As a utility it seems that
The possible result of |
I'm not positive warehouse's behavior is correct here either. Seems we might need a validator utility in packaging that ensures a given distribution name is valid? Currently warehouse defines the regex from PEP 508 inline at https://github.com/pypa/warehouse/blob/ea21a674b6165d61340ae976da67a08729902f6a/warehouse/forklift/legacy.py#L199-L201 |
It may make sense for warehouse to use canonicalize name in the comparison noted by @pradyunsg at https://github.com/pypa/warehouse/blob/ea21a674b6165d61340ae976da67a08729902f6a/warehouse/forklift/legacy.py#L1192-L1193, however I'm concerned that this might paper over the impedance mismatch noted in #743 (comment) |
Hmm... I wonder how disruptive it would be to require the incoming names (going "into" PyPI) to be canonical as PEP 503 defines. The benefit is that PyPI (and publishing tooling) would only use PEP 503 names (other than for validation / legacy projects) and pip (and other consumption tooling) would need to deal with PEP 508 stuff. |
That would certainly break valid distribution names like |
I guess one final thought here specifically is that what we're calling namespaces here should probably be spoken as "pseudonamespaces" since there is really no implication to them in the project name currently. Actual namespace support is something that has been discussed and is likely to see fruition in the near future. |
…ity (#745) * Fix the "safe_name" attribute of PackageFile for backwards compatibility Commit 0bd26af introduced a regression that was causing some namespace packages with dots in them fail to upload to PyPI. The reason is because `packaging.utils.canonicalize_name()` is not equivalent to `pkg_resources.safe_name()` as the former transforms the "." into "-", while the later only does it for non-alphanumeric/. characters. Closes: #743 * Update docstring of safe_name() Co-authored-by: Brian Rutledge <brian@bhrutledge.com> Co-authored-by: Brian Rutledge <brian@bhrutledge.com>
The fix has been released: https://pypi.org/project/twine/3.4.1/ Thanks @pablogsal for the quick fix, and @Bengt and @godlygeek for the initial report. |
I can confirm that 3.4.1 fixes all issues I was having. Thanks for all the discussion and the quick fix, everybody. |
@Bengt thanks for the excellent report that made it easy to track down and fix this |
Your Environment
python:slim-buster
3.7.8
pip from official PyPI
twine-3.4.0-py3-none-any.whl
PKG-INFO
file.pypirc
fileThe Issue
When I run twine, I get an error:
Source: https://gitlab.com/offis.energy/mosaik/mosaik.simconfig/-/jobs/1100239627
Additional occurrences:
https://gitlab.com/mosaik.hdf5-storage/mosaik.hdf5-storage/-/jobs/1100176050
https://gitlab.com/offis.energy/mosaik/mosaik.scenario-tools/-/jobs/1100175841
https://gitlab.com/offis.energy/mosaik/mosaik.eid/-/jobs/1100176922
https://gitlab.com/offis.energy/mosaik/mosaik.householdsim_semver/-/jobs/1100175569
Steps to Reproduce
Source: https://gitlab.com/offis.energy/mosaik/mosaik.simconfig/-/blob/master/.gitlab-ci.yml#L88
The text was updated successfully, but these errors were encountered: