pygplates.Version
- class pygplates.Version
Bases:
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]
whereN.N.N
is the major.minor.patch version and(.dev|a|b|rc)N
is an optional pre-release suffix. Examples include1.0.0
for an official release,1.0.0.dev1
for a first development pre-release and1.0.0rc1
for a first release candidate.All comparison operators (==, !=, <, <=, >, >=) are supported and
Version
is hashable (can be used as a key in adict
). AndVersion
can be pickled.During the lifespan of pyGPlates, theimported 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 version0.36
(the official beta public release of pyGPlates in 2022) 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, 36): raise RuntimeError('Using pygplates version {0} but version {1} or greater is required'.format( pygplates.Version.get_imported_version(), pygplates.Version(0, 36)))
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: 1.0.0rc1
.There is also a
pygplates.__version__
string which will also print1.0.0rc1
.Changed in version 0.42: Added pickle support.
- __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 toNone
)- 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.34
:version = pygplates.Version(0, 34)
Added in version 0.34.
- __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')
Added in version 0.34.
__init__(revision)
Only supported when revision <= 33 (where creates version 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...
[staticmethod] Return the version of the imported pyGPlates library.
Return the major version number.
Return the minor version number.
Return the patch version number.
Return the pre-release PEP440 suffix (matching pattern
(.dev|a|b|rc)N
), orNone
if not a pre-release.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:
To get the imported version:
imported_version = pygplates.Version.get_imported_version()
- get_major()
Return the major version number.
- Return type:
int
Added in version 0.34.
- get_minor()
Return the minor version number.
- Return type:
int
Added in version 0.34.
- get_patch()
Return the patch version number.
- Return type:
int
Added in version 0.34.
- get_prerelease_suffix()
Return the pre-release PEP440 suffix (matching pattern
(.dev|a|b|rc)N
), orNone
if not a pre-release.- Return type:
str or None
Added in version 0.34.
- 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.