IDAES Versioning

The IDAES Python package is versioned according to the general guidelines of semantic versioning, following the recommendations of PEP 440 with respect to extended versioning descriptors (alpha, beta, release candidate, etc.).

Basic usage

You can see the version of the package at any time interactively by printing out the __version__ variable in the top-level package:

import idaes
print(idaes.__version__)
# prints a version like "1.2.3"

Advanced usage

This section describes the module’s variables and classes.

Overview

The API in this module is mostly for internal use, e.g. from ‘setup.py’ to get the version of the package. But Version has been written to be usable as a general versioning interface.

Example of using the class directly:

>>> from idaes.ver import Version
>>> my_version = Version(1, 2, 3)
>>> print(my_version)
1.2.3
>>> tuple(my_version)
(1, 2, 3)
>>> my_version = Version(1, 2, 3, 'alpha')
>>> print(my_version)
1.2.3.a
>>> tuple(my_version)
(1, 2, 3, 'alpha')
>>> my_version = Version(1, 2, 3, 'candidate', 1)
>>> print(my_version)
1.2.3.rc1
>>> tuple(my_version)
(1, 2, 3, 'candidate', 1)

If you want to add a version to a class, e.g. a model, then simply inherit from HasVersion and initialize it with the same arguments you would give the Version constructor:

>>> from idaes.ver import HasVersion
>>> class MyClass(HasVersion):
...     def __init__(self):
...         super(MyClass, self).__init__(1, 2, 3, 'alpha')
...
>>> obj = MyClass()
>>> print(obj.version)
1.2.3.a
idaes.ver.package_version = <idaes.ver.Version object>

Package’s version as an object

idaes.ver.__version__ = '1.2.1'

Package’s version as a simple string

Version class

The versioning semantics are encapsulated in a class called Version.

class idaes.ver.Version(major, minor, micro, releaselevel='final', serial=None)[source]

This class attempts to be compliant with a subset of PEP 440.

Note: If you actually happen to read the PEP, you will notice that pre- and post- releases, as well as “release epochs”, are not supported.

__init__(major, minor, micro, releaselevel='final', serial=None)[source]

Create new version object.

Provided arguments are stored in public class attributes by the same name.

Parameters:
  • major (int) – Major version
  • minor (int) – Minor version
  • micro (int) – Micro (aka patchlevel) version
  • releaselevel (str) – Optional PEP 440 specifier
  • serial (int) – Optional number associated with releaselevel
__iter__()[source]

Return version information as a sequence.

__str__()[source]

Return version information as a string.

HasVersion class

For adding versions to other classes in a simple and standard way, you can use the HasVersion mixin class.

class idaes.ver.HasVersion(*args)[source]

Interface for a versioned class.

__init__(*args)[source]

Constructor creates a version attribute that is an instance of Version initialized with the provided args.

Parameters:*args – Arguments to be passed to Version constructor.