utils.canonicalize_version produces an abnormal version
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 751
- Forks
- 324
- Avg merge
- 12h 58m
- Merged PRs (30d)
- 3
Description
In https://github.com/pypa/setuptools/issues/4302, we learned that using packaging.utils.canonicalize_version to canonicalize a version produces an aberrant version.
@ pip-run packaging -- -c 'import packaging.utils; print(packaging.utils.canonicalize_version("69.3.0"))'
69.3
Instead of matching the convention of wheels, which will produce a wheel with a version of "69.3.0", canonicalize_version strips the trailing zero and produces 69.3.
Moreover, semver indicates that the version number should include a trailing zero, so it's not possible to honor both semver and the canonicalized_version.
In https://github.com/pypa/setuptools/issues/3593#issuecomment-2052518260, @pfmoore says that wheels and sdists should use the same format.
What's the correct format?
Also, why does a function called canonicalize_version produce both canonical and non-canonical versions depending on a flag?
I see that wheel implements its own safer_version function.
If packaging.utils.canonicalize_version isn't the right implementation for a PEP 625 canonicalized version, what is?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/packaging/utils.py at the linked canonicalize_version implementation, then compare its behavior with wheel/bdist_wheel.py's safer_version and the referenced setuptools discussions. Determine the intended PEP 625, wheel, and semver behavior and clarify whether the flag and resulting API need changing. Done means the expected format and implementation path are agreed and covered by relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100