easybuild.framework.easyconfig.format.version module

This describes the easyconfig version class. To be used in EasyBuild for anything related to version checking

author:Stijn De Weirdt (Ghent University)
author:Kenneth Hoste (Ghent University)
class easybuild.framework.easyconfig.format.version.EasyVersion(vstring=None)

Bases: distutils.version.LooseVersion

Exact LooseVersion. No modifications needed (yet)

class easybuild.framework.easyconfig.format.version.OrderedVersionOperators

Bases: object

Ordered version operators. The ordering is defined such that one can test from left to right, and assume that the first matching version operator is the one that is the best match.

Example: ‘> 2’, ‘> 3’ should be ordered [‘> 3’, ‘> 2’], because for 4, both match, but 3 is considered more strict.

Conflicting version operators are not allowed.

add(versop_new, data=None, update=None)

Try to add argument as VersionOperator instance to current list of version operators. Make sure there is no conflict with existing versops, and that the ordering is maintained. After add, versop_new is in the OrderedVersionOperators. If the same versop_new was already in it, it will update the data (if not None) (and not raise an error)

Parameters:
  • versop_new – VersionOperator instance (or will be converted into one if type basestring)
  • data – additional data for supplied version operator to be stored
  • update – if versop_new already exist and has data set, try to update the existing data with the new data; instead of overriding the existing data with the new data (method used for updating is .update)
get_data(versop)

Return the data for versop from datamap

class easybuild.framework.easyconfig.format.version.ToolchainVersionOperator(tcversop_str=None)

Bases: easybuild.framework.easyconfig.format.version.VersionOperator

Class which represents a toolchain and versionoperator instance

as_dict()

Return toolchain version operator as a dictionary with name/version keys. Returns None if translation to a dictionary is not possible (e.g. non-equals operator, missing version, ...).

is_valid()

Check if this is a valid ToolchainVersionOperator

parse_versop_str(tcversop_str)

If argument matches a toolchain versop, return dict with toolchain name and version, and optionally operator. Otherwise, return None.

set(tcversop_str)

Parse argument as toolchain version string, and set attributes. Returns None in case of failure (e.g. if supplied string doesn’t parse), True in case of success.

test(name, version)
Check if a toolchain with name name and version version would fit
in this ToolchainVersionOperator
Parameters:
  • name – toolchain name
  • version – a version string or EasyVersion instance
versop_regex()

Create the regular expression for toolchain support of format ^<toolchain> <versop_expr>$ , with <toolchain> the name of one of the supported toolchains and <versop_expr> in ‘<operator> <version>’ syntax

class easybuild.framework.easyconfig.format.version.VersionOperator(versop_str=None, error_on_parse_failure=False)

Bases: object

VersionOperator class represents a version expression that includes an operator.

DEFAULT_UNDEFINED_OPERATOR()

eq(a, b) – Same as a==b.

DEFAULT_UNDEFINED_VERSION = LooseVersion ('0.0.0')
DEFAULT_UNDEFINED_VERSION_OPERATOR()

gt(a, b) – Same as a>b.

DICT_SEPARATOR = ':'
INCLUDE_OPERATORS = ['==', '>=', '<=']
OPERATOR_FAMILIES = [['>', '>='], ['<', '<=']]
OPERATOR_MAP = {'==': <built-in function eq>, '<=': <built-in function le>, '>=': <built-in function ge>, '<': <built-in function lt>, '>': <built-in function gt>}
ORDERED_OPERATORS = ['==', '>', '>=', '<', '<=']
REVERSE_OPERATOR_MAP = {<built-in function ge>: '>=', <built-in function eq>: '==', <built-in function le>: '<=', <built-in function lt>: '<', <built-in function gt>: '>'}
SEPARATOR = ' '
get_version_str()

Return string representation of version (ignores operator).

is_valid()

Check if this is a valid VersionOperator. Suffix can be anything.

k = '>'
parse_error(msg)

Special function to deal with parse errors

parse_versop_str(versop_str, versop_dict=None)

If argument contains a version operator, returns a dict with version and operator; returns None otherwise :param versop_str: the string to parse :param versop_dict: advanced usage: pass intialised versop_dict (eg for ToolchainVersionOperator)

set(versop_str)

Parse argument as a version operator, and set attributes. Returns True in case of success, throws an error in case of parsing failure.

test(test_version)
Convert argument to an EasyVersion instance if needed, and return self.operator(<argument>, self.version)
Versions only, no suffix.
Parameters:test_version – a version string or EasyVersion instance
test_overlap_and_conflict(versop_other)

Test if there is any overlap between this instance and versop_other, and if so, if there is a conflict or not.

Returns 2 booleans: has_overlap, is_conflict

Parameters:versop_other – a VersionOperator instance
Examples:

‘> 3’ and ‘> 3’ : equal, and thus overlap (no conflict) ‘> 3’ and ‘< 2’ : no overlap ‘< 3’ and ‘> 2’ : overlap, and conflict (region between 2 and 3 is ambiguous) ‘> 3’ and ‘== 3’ : no overlap ‘>= 3’ and ‘== 3’ : overlap, and conflict (boundary 3 is ambigous) ‘> 3’ and ‘>= 3’ : overlap, no conflict (‘> 3’ is more strict then ‘>= 3’)

# suffix ‘> 2 suffix:-x1’ > ‘> 1 suffix:-x2’: suffix not equal, conflict

v()

gt(a, b) – Same as a>b.

versop_regex(begin_end=True)

Create the version regular expression with operator support. This supports version expressions like ‘> 5’ (anything strict larger than 5), or ‘<= 1.2’ (anything smaller than or equal to 1.2) :param begin_end: boolean, create a regex with begin/end match