Version

This is a helper class to work with versions, it splits the version string based on dots and hyphens. It exposes all the version components as properties and offers total ordering through compare operators.

Comparing versions

  1. compiler_lower_than_12 = Version(self.settings.compiler.version) < "12.0"
  2. is_legacy = Version(self.version) < 2

class Version(value, qualifier=False)

This is NOT an implementation of semver, as users may use any pattern in their versions. It is just a helper to parse “.” or “-” and compare taking into account integers when possible

Attributes

The Version class offers ways to access the different parts of the version number:

main

Get all the main digits.

  1. v = Version("1.2.3.4-alpha.3+b1")
  2. assert [str(i) for i in v.main] == ['1', '2', '3', '4', '5']

major

Get the major digit.

  1. v = Version("1.2.3.4-alpha.3+b1")
  2. assert str(v.major) == "1"

minor

Get the minor digit.

  1. v = Version("1.2.3.4-alpha.3+b1")
  2. assert str(v.minor) == "2"

patch

Get the patch digit.

  1. v = Version("1.2.3.4-alpha.3+b1")
  2. assert str(v.patch) == "3"

micro

Get the micro digit.

  1. v = Version("1.2.3.4-alpha.3+b1")
  2. assert str(v.micro) == "4"

pre

Get the pre-release digit.

  1. v = Version("1.2.3.4-alpha.3+b1")
  2. assert str(v.pre) == "alpha.3"

build

Get the build digit.

  1. v = Version("1.2.3.4-alpha.3+b1")
  2. assert str(v.build) == "b1"