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)

  • versop_new – VersionOperator instance (or will be converted into one if type string)
  • 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)

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


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, …).


Check if this is a valid ToolchainVersionOperator


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


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
  • name – toolchain name
  • version – a version string or EasyVersion instance

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.


Same as a == b.

DEFAULT_UNDEFINED_VERSION = LooseVersion ('0.0.0')

Same as a > b.

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

Return string representation of version (ignores operator).


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


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)


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

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 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

‘> 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


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