← 输入框|github.com|刷新
Skip to content

Semver versioning is incompatible with pypi dist cleansing #335

Closed

Description

@KitBurgess

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

Activity

  1. added
    Bug
    on Dec 31, 2020
  2. tomschr commented on Dec 31, 2020

    @tomschr
    Member

    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.

  3. removed
    Bug
    on Dec 31, 2020
  4. tomschr commented on Jan 1, 2021

    @tomschr
    Member

    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?

  5. added
    Doc
    on Jan 11, 2022
  6. tomschr commented on Jan 27, 2022

    @tomschr
    Member

    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! ❤️

  7. tomschr commented on Feb 11, 2022

    @tomschr
    Member

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Doc

    Type

    No type

    Fields

    SIze

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions