Skip to content
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

Should PyPI Purl Versions have _ replaced with - (like Name) #130

Open
samuelmakarovskiy opened this issue Nov 1, 2023 · 1 comment
Open

Comments

@samuelmakarovskiy
Copy link

In this code blob, seems PyPI purls have _ replaced with - in the name field. This is likely to align with the purlspec:
https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#pypi

However, the wording here gives "name" as an example field where this replacement needs to happen.

For pre-release pypi purls like pkg:pypi/[email protected]_rc_2

Should the version be converted to 4.21.0-rc-2 instead of 4.21.0_rc_2?

@samuelmakarovskiy samuelmakarovskiy changed the title Should PyPI Purl Versions have _ replaced with - (like name) Should PyPI Purl Versions have _ replaced with - (like Name) Nov 1, 2023
@pombredanne
Copy link
Member

The version should not be normalized the same a name is normalized IMHO. And things are likely more complex than this. Here is what the "packaging" library returns. This is the standard library to parse and normalize versions. This is not semver BTW.

>>> from packaging import version
>>> version.Version("4.21.0_rc_2")
<Version('4.21.0rc2')>
>>> version.Version("4.21.0-rc-2")
<Version('4.21.0rc2')>
>>> version.Version("4.21.0-rc2")
<Version('4.21.0rc2')>

This is based on the https://peps.python.org/pep-0440/ standard now at https://packaging.python.org/en/latest/specifications/version-specifiers/#version-specifiers
The spec should be updated accordingly IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants