pygplates.Version

class pygplates.Version

Bases: Boost.Python.instance

A version of pyGPlates (GPlates Python API).

Versions are defined by the PEP440 versioning scheme as N.N.N[(.dev|a|b|rc)N] where N.N.N is the major.minor.patch version and (.dev|a|b|rc)N is an optional pre-release suffix. Examples include 1.0.0 for an official release, 1.0.0.dev1 for a first development pre-release and 1.0.0rc1 for a first release candidate.

All comparison operators (==, !=, <, <=, >, >=) are supported and Version is hashable (can be used as a key in a dict).

During the lifespan of pyGPlates, the imported pyGPlates version has been updated for each API change. So it can be used to ensure new API additions are present in the imported pyGPlates library.
For example, if we are using an API function that was added in version 0.28 (the official beta public release of pyGPlates in 2020, known at the time as revision 28) then we can ensure we are using a sufficient API version by checking this at the beginning of our script:
if pygplates.Version.get_imported_version() < pygplates.Version(0, 28):
    raise RuntimeError('Using pygplates version {0} but version {1} or greater is required'.format(
        pygplates.Version.get_imported_version(), pygplates.Version(0, 28)))

To print the version string of the imported pyGPlates library:

print('imported pyGPlates version: {}'.format(pygplates.Version.get_imported_version()))

…which, for this version of pyGPlates, will print imported pyGPlates version: 0.36.0.

There is also a pygplates.__version__ string which will also print 0.36.0.

__init__(...)

A Version object can be constructed in more than one way…

__init__(major, minor, [patch=0], [prerelease_suffix])

Create from major, minor, patch numbers and optional pre-release suffix string.

param major

the major version number

type major

int

param minor

the minor version number

type minor

int

param patch

the patch version number (defaults to zero)

type patch

int

param prerelease_suffix

the optional pre-release PEP440 suffix (.dev|a|b|rc)N (defaults to None)

type prerelease_suffix

string or None

raises

ValueError if prerelease_suffix is specified but doesn’t match pattern (.dev|a|b|rc)N

To create version 0.28:

version = pygplates.Version(0, 28)
__init__(version)

Create from a version string.

param version

the version string in PEP440 format matching N.N[.N][(.dev|a|b|rc)N]

type version

string

raises

ValueError if version string doesn’t match pattern N.N[.N][(.dev|a|b|rc)N]

To create the first development pre-release of version 0.34:

version = pygplates.Version('0.34.dev1')

__init__(revision)

Only supported for versions <= 0.33 (where created version is 0.revision).

param revision

the revision number

type revision

int

raises

RuntimeError if revision is greater than 33

Deprecated since version 0.34.

Methods

__init__(...)

A Version object can be constructed in more than one way...

get_imported_version()

[staticmethod] Return the version of the imported pyGPlates library.

get_major()

Return the major version number.

get_minor()

Return the minor version number.

get_patch()

Return the patch version number.

get_prerelease_suffix()

Return the pre-release PEP440 suffix (matching pattern (.dev|a|b|rc)N), or None if not a pre-release.

get_revision()

Only supported for versions <= 0.33 (with zero patch number and no pre-release suffix).

static get_imported_version()

[staticmethod] Return the version of the imported pyGPlates library.

Returns

a Version instance representing the version of the imported pyGPlates library

Return type

Version

To get the imported version:

imported_version = pygplates.Version.get_imported_version()
get_major()

Return the major version number.

Return type

int

get_minor()

Return the minor version number.

Return type

int

get_patch()

Return the patch version number.

Return type

int

get_prerelease_suffix()

Return the pre-release PEP440 suffix (matching pattern (.dev|a|b|rc)N), or None if not a pre-release.

Return type

str or None

get_revision()

Only supported for versions <= 0.33 (with zero patch number and no pre-release suffix).

Returns

the minor version number

Return type

int

Raises

RuntimeError if internal version is not <= 0.33 (with zero patch number and no pre-release)

Deprecated since version 0.34.