[Python-ideas] Allowing semver in packaging

Daniel Holth dholth at gmail.com
Wed Oct 31 19:04:45 CET 2012


Or Changing the Version Comparison Module in Distutils (again)

We've discussed a bit on distutils-sig about allowing
http://semver.org/versions in Python packages. Ronald's suggestion to
replace - with ~ as a
filename parts separator made me think of it again, because semver also
uses the popular - character.

The gist of semver:

Major.Minor.Patch (always 3 numbers)

1.0.0-prerelease.version
1.0.0+postrelease.version
1.0.0-pre+post

And the big feature: no non-lexicographical sorting.

Right now, setuptools replaces every run of non-alphanumeric characters in
versions (and in project names) to a single dash (-). This would have to
change to at least allow +, and the regexp for recognizing an installed
dist would have to allow the plus as well. Current setuptools handling:

def safe_version(version):
    version = version.replace(' ','.')
    return re.sub('[^A-Za-z0-9.]+', '-', version)


Semver would be an upgrade from the existing conventions because it is easy
to remember (no special-case sorting for forgettable words 'dev' and
'post'), because you can legally put Mercurial revision numbers in your
package's pre- or post- version, and because the meaning of Major, Minor,
Patch is defined. For compatibility I think it would be enough to say you
could not mix semver and PEP-386 in the same major.minor.patch release.

Vinay Sajip's distlib has some experimental support for semver.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121031/087f2cf4/attachment.html>


More information about the Python-ideas mailing list