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

Semver versioning is incompatible with pypi dist cleansing #335

Closed
KitBurgess opened this issue Dec 31, 2020 · 4 comments
Closed

Semver versioning is incompatible with pypi dist cleansing #335

KitBurgess opened this issue Dec 31, 2020 · 4 comments
Labels
Doc Documentation related issue

Comments

@KitBurgess
Copy link

Situation

The Semver package doesn't correctly characterise versions, raising errors for valid semver tags.

To Reproduce

VersionInfo.parse("3.0.0.dev0")

  File "~/myrepo/venv/lib/python3.7/site-packages/semver.py", line 726, in parse
    raise ValueError("%s is not valid SemVer string" % version)
ValueError: 3.0.0.dev0 is not valid SemVer string

Expected Behavior

3.0.0.dev0 is a valid semver tag, no error should be thrown

Environment

Python3.7, semver 2.13.0

@KitBurgess KitBurgess added the Bug Error, flaw or fault to produce incorrect or unexpected results label Dec 31, 2020
@tomschr
Copy link
Member

tomschr commented Dec 31, 2020

Hi @KitBurgess thanks for your report, much appreciated. 👍

Well, I fear, your example is not a valid semver version. According to the semver specification, version core (the major, minor, patch part) is separated by a "-" (dash) from the prerelease dev0). Your example contains a dot which is an invalid character. So the exception is correct.

If you change your example to "3.0.0-dev0" this would be a valid semver version and accepted.

Hope this helps.

@tomschr tomschr removed the Bug Error, flaw or fault to produce incorrect or unexpected results label Dec 31, 2020
@tomschr
Copy link
Member

tomschr commented Jan 1, 2021

Happy new year! 🎉 😁

Maybe I completely misunderstood your intention, but here is a second thought.
Do you mean the version from PyPI?

This is indeed an invalid semver version. However, I can't influence that as it is created automatically by setup.py sdist (run by tox -e prepare-dist).

If you want to convert such versions, you could do that with the packaging.version module like this:

>>> from packaging import version
>>> from semver import VersionInfo

>>> v = version.Version("3.0.0.dev2")
>>> VersionInfo(*v.release, prerelease="dev.%s" % v.dev)
VersionInfo(major=3, minor=0, patch=0, prerelease='dev.2', build=None

I think, it could be a helpful addition to our documentation. Would that help?

@tomschr tomschr added the Doc Documentation related issue label Jan 11, 2022
@tomschr
Copy link
Member

tomschr commented Jan 27, 2022

Hi @KitBurgess,

I've created a PR #352 based on our conversation, sorry for the delay. Would this help? If you like and have time, could you review the PR? That would be very helpful for me. Thanks! ❤️

@tomschr
Copy link
Member

tomschr commented Feb 11, 2022

As the PR is already merged and I didn't get any response, I assume it was okay. If there are still some questions, reopen it.

Thanks!

@tomschr tomschr closed this as completed Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Doc Documentation related issue
Projects
None yet
Development

No branches or pull requests

2 participants