setuptools: [BUG] Wheel naming is not following PEP 491 convention
setuptools version
setuptools==66.0.0
Python version
python 3.8
OS
macOS
Additional environment information
No response
Description
I am building a wheel for a python package using setuptools and it seems that the naming of my wheel file is not respecting the PEP 491 convention.
For external reasons, I need to name my package with the structure {namespace}.{package-name}. If I follow the convention, I would expect that my wheel file is named: namespace_package_name-0.1.0-py2.py3-none-any.whl.
However, I get this name for my wheel: namespace.package_name-0.1.0-py2.py3-none-any.whl, which is not respecting the convention.
Expected behavior
I expect the “.” in the package name to be replaced with a “_” in the wheel name.
How to Reproduce
- create a hello_world package structure:
hello_world |- my_package | |- __init__.py | |- hello_world.py |- pyproject.toml |- setup.cfg - in
setup.cfg, write:[metadata] name = namespace.my-package version = 0.1.0 [options] zip_safe = False include_package_data = True packages = find: - in
project.toml, write:[build-system] requires = ["setuptools==66.0.0", "wheel"] build-backend = "setuptools.build_meta" - run
pipx run buildat the root of your hello_world package - inspect the
distdirectory which was created
Output
in the dist folder, you find:
namespace.my_package-0.1.0-py3-none-any.whl
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 19 (13 by maintainers)
Commits related to this issue
- Publish: Workaround using raw filename Since setuptools violates the wheel filenames spec (https://github.com/pypa/setuptools/issues/3777), we have to use the raw filename when publishing to get thro... — committed to astral-sh/uv by konstin 2 years ago
- fix(tools): handle packages with dots in their names during dependency checks The `setuptools` package starting with `v70.1.0`[1] contains built-in `bdist_wheel` command. Before this version `setupto... — committed to espressif/esp-idf by fhrbata 2 years ago
- fix(tools): handle packages with dots in their names during dependency checks The `setuptools` package starting with `v70.1.0`[1] contains built-in `bdist_wheel` command. Before this version `setupto... — committed to espressif/esp-idf by fhrbata 2 years ago
- fix(tools): handle packages with dots in their names during dependency checks The `setuptools` package starting with `v70.1.0`[1] contains built-in `bdist_wheel` command. Before this version `setupto... — committed to espressif/esp-idf by fhrbata 2 years ago
- fix(tools): handle packages with dots in their names during dependency checks The `setuptools` package starting with `v70.1.0`[1] contains built-in `bdist_wheel` command. Before this version `setupto... — committed to espressif/esp-idf by fhrbata 2 years ago
- fix(tools): handle packages with dots in their names during dependency checks The `setuptools` package starting with `v70.1.0`[1] contains built-in `bdist_wheel` command. Before this version `setupto... — committed to espressif/esp-idf by fhrbata 2 years ago
- fix(tools): handle packages with dots in their names during dependency checks The `setuptools` package starting with `v70.1.0`[1] contains built-in `bdist_wheel` command. Before this version `setupto... — committed to espressif/esp-idf by fhrbata 2 years ago
Took a shot at fixing this bug, I think https://github.com/pypa/setuptools/pull/4766 will resolve it but there’s one failing test that I haven’t been able to figure out.
Hi @jaraco, there was a discussion recently on the Python discourse about the normalisation of the distribution file names https://discuss.python.org/t/change-in-pypi-upload-behavior-intentional-accidental-pebkac/27707. I will try to summarise the key takeaways I found on why most of the community seems to be in favour of the normalisation. Hopefully this answers the question “What was the motivation for mangling them?”:
pip, whose primary use case is to download from PyPI, prefers to rule out the possibility of treating distributions named after namespace packages and “normal packages” as two different distributions. This is compatible with PyPI and also helps users to fix unintentional typing errors and avoid downloading wrong/malicious distributions..dist-info/.egg-infodirectory (faster lookup), and if I understood correct this would also help to optimise the checks for conflicting distributions already installed (since.dist-infoserves as a database).a.banda_bto coexist in the same private index.Namein thePKG-INFO/METADATAfiles should not be normalised and reflect the user’s input.So it seems that the name change unlocks optimisations and simplifications.
@bastienqb, if you would like you can chip in the discussion on https://discuss.python.org/t/change-in-pypi-upload-behavior-intentional-accidental-pebkac/27707 to explain why keeping the names in the format
{namespace}.{package-name}is important. Otherwise there seems to be a push in the community for a strict standard that normalises the file name (as a mean to unlock the optimisations and simplifications I mentioned before).Fixed the failing test in #4766, so there shouldn’t be any other blockers here.
FYI, we’d like to start warning about this on PyPI, but don’t want to do that until users have an upgrade path to a setuptools version which produces the correct filenames: https://github.com/pypi/warehouse/issues/17377
I concede. It doesn’t matter what the motivation was to consider
.and_equivalent, but they are now by consensus.