Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Version identifier management

Project Description

The verschemes package provides easy and customizable version identifier management in Python. It supports defining custom version schemes in a subclass of the Version class. Instances of Version and its subclasses are concrete versions guaranteed to follow the rules of the class from which they were instantiated.

The source, documentation, and issues are hosted on GitHub.

This is an open-source project by and for the community. Contributions, suggestions, and questions are welcome (Twitter: @bravegnuworld).


Version 1.1 introduces a backwards-incompatible change: Version instances are now immutable. See the Release Notes for details.



Most versioned components have their own method of identifying their versions. This method is often termed “versioning” or called a “version scheme”. The method is simply a set of rules that dictate what is a valid version identifier and is usually separated (often by delimiters, such as a dot) in a number of segments to signify hierarchy among the versions. The hierarchy determines ordering along with the values of the segments within the hierarchy.


In the verschemes library, a version scheme is a set of rules pertaining to the identification of versions for a given scope or purpose. Each version contains a number of segments often separated by delimiters. Each segment is allowed to have multiple fields to identify portions of the segment, though many segments have just one field.

Many version schemes are just integers separated by dots. The base Version class works fine for generic version numbers that fit this scheme, but the real power of this library is in defining version schemes (Version subclasses) with segments that specifically describe the scheme and automatically implement validation and normalized rendering of a version identifier or a sequence of version segment values. The SEGMENT_DEFINITIONS attribute of a Version subclass can be used to define the specific parameters of the version scheme that is represented by that class.

The library also contains some implementations of specific version schemes including Python, PEP 440, PostgreSQL, and versioning. More are sure to be added, and submissions of version shemes for popular, public projects/systems are welcome. These implementations also serve as examples for those wishing to subclass Version for their own (or another’s) version scheme.



>>> from verschemes import Version
>>> from verschemes.python import PythonVersion, PythonMinorVersion
>>> from verschemes.pep440 import Pep440Version

Instantiation from a string

>>> Version("3.1.4")
verschemes.Version(3, 1, 4)
>>> Pep440Version("3.1.4")
verschemes.pep440.Pep440Version(None, 3, 1, 4, None, None, None, None, None, None)

Instantiation from segment values

>>> Version(3, 1, 4)
verschemes.Version(3, 1, 4)
>>> PythonVersion(3, 1, 4, ["b", 5])
verschemes.python.PythonVersion(3, 1, 4, Segment(releaselevel='b', serial=5))
>>> Pep440Version(None, 3, 1, 4)
verschemes.pep440.Pep440Version(None, 3, 1, 4, None, None, None, None, None, None)

Instantiation from named segment values

>>> PythonVersion(major=3, minor=1, micro=4)
verschemes.python.PythonVersion(3, 1, 4, None)
>>> Pep440Version(release1=3, release2=1, release3=4)
verschemes.pep440.Pep440Version(None, 3, 1, 4, None, None, None, None, None, None)
>>> Pep440Version(epoch=2, release1=3, release2=1, release3=4, post_release=7)
verschemes.pep440.Pep440Version(2, 3, 1, 4, None, None, None, None, 7, None)


>>> version = Version(3, 1, 4)
>>> str(version)
>>> version.render()
>>> version = Pep440Version("3.1.4b5", epoch=2)
>>> str(version)
>>> version.render(min_release_segments=4)


>>> Version("3.1.4") == Version(3, 1, 4)
>>> Version("3.1.10") > Version("3.1.4")
>>> PythonVersion(3, 1, 4, ["b", 5]).minor_version == PythonMinorVersion(3, 1)


>>> str(Version("3.01.0004"))
>>> str(Pep440Version("3.1.4-dev5"))
>>> str(Pep440Version("3.1.4post6"))
>>> str(Pep440Version("3.1.4.RC7"))


>>> version = PythonVersion(3, 1, 4, ["b", 5])
>>> version.major
>>> version.minor
>>> version.micro
>>> version.suffix.releaselevel
>>> version.suffix.serial
>>> version.is_release
>>> version.is_nondevelopment
>>> Pep440Version("3.1.4").is_release
>>> Pep440Version("3.1.4a2").is_release


>>> version = Version(3, 1, 4)
>>> new_version = version.replace(_0=2)
>>> str(new_version)
>>> version = PythonVersion(3, 1, 4)
>>> new_version = version.replace(major=2)
>>> str(new_version)

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(18.8 kB) Copy SHA256 Hash SHA256
Source None Jul 30, 2014

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting