Versioning

The pyTooling.Versioning package provides auxiliary classes to implement semantic and calendar versioning.

Semantic Versioning

The SemanticVersion class represents of a version number like v3.7.12.

Example

# Construct from string
version1 = SemanticVersion("0.22.8")

# Construct from numbers
version2 = SemanticVersion(1, 3, 0)

# Compare versions
isNewer = version2 > version1

Hint

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,

  • MINOR version when you add functionality in a backwards compatible manner, and

  • PATCH version when you make backwards compatible bug fixes.

  • Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

Summary taken from semver.org.

Features

  • Major, minor, patch, build numbers

  • Comparison operators

  • Construct version number object from string or numbers.

Missing Features

  • preserve prefix letter like v, r

  • pre-version and post-version

  • additional labels like dev, rc, pl, alpha

Calendar Versioning

The CalendarVersion class represents of a version number like 2021.10.

Example

# Construct from string
version1 = CalendarVersion("2018.3")