Skip to content

version

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

Authors:

  • Stijn De Weirdt (Ghent University)
  • Kenneth Hoste (Ghent University)

EasyVersion

Bases: LooseVersion

Exact LooseVersion. No modifications needed (yet)

__hash__()

Return hash for this object.

__len__()

Determine length of this EasyVersion instance.

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.

__init__()

Initialise the list of version operators as an empty list.

__str__()

Print the list and map

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)

PARAMETER DESCRIPTION
versop_new

VersionOperator instance (or will be converted into one if type string)

data

additional data for supplied version operator to be stored

DEFAULT: None

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)

DEFAULT: None

get_data(versop)

Return the data for versop from datamap

ToolchainVersionOperator

Bases: VersionOperator

Class which represents a toolchain and versionoperator instance

__hash__()

Return hash for this object.

__init__(tcversop_str=None)

Initialise VersionOperator instance.

PARAMETER DESCRIPTION
tcversop_str

intialise with toolchain version operator string

DEFAULT: None

__str__()

Return string representation of this 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

PARAMETER DESCRIPTION
name

toolchain name

version

a version string or EasyVersion instance

versop_regex()

Create the regular expression for toolchain support of format ^ $ , with the name of one of the supported toolchains and in ' ' syntax

VersionOperator

Bases: object

VersionOperator class represents a version expression that includes an operator.

__bool__()

Interpretation of a VersionOperator instance as a boolean expression: is it valid?

__eq__(versop)

Compare this instance to supplied argument.

__gt__(versop_other)

Determine if this instance is greater than supplied argument.

Returns True if it is more strict in case of overlap, or if self.version > versop_other.version otherwise. Returns None in case of conflict.

PARAMETER DESCRIPTION
versop_other

a VersionOperator instance Examples: '> 2' > '> 1' : True, order by strictness equals order by boundaries for >, >= '< 8' > '< 10': True, order by strictness equals inversed order by boundaries for <, <= '== 4' > '> 3' : equality is more strict than inequality, but this order by boundaries '> 3' > '== 2' : there is no overlap, so just order the intervals according their boundaries '> 1' > '== 1' > '< 1' : no overlap, same boundaries, order by operator suffix: '> 2' > '> 1': both equal (both None), ordering like above '> 2 suffix:-x1' > '> 1 suffix:-x1': both equal (both -x1), ordering like above '> 2 suffix:-x1' > '> 1 suffix:-x2': not equal, conflict

__hash__()

Return hash for this object.

__init__(versop_str=None, error_on_parse_failure=False)

Initialise VersionOperator instance.

PARAMETER DESCRIPTION
versop_str

intialise with version operator string

DEFAULT: None

error_on_parse_failure

raise EasyBuildError in case of parse error

DEFAULT: False

__ne__(versop)

Is self not equal to versop

__repr__()

Return instance as string (ignores begin_end)

__str__()

Return string representation of this VersionOperator instance

get_version_str()

Return string representation of version (ignores operator).

is_valid()

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

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

PARAMETER DESCRIPTION
versop_str

the string to parse

versop_dict

advanced usage: pass intialised versop_dict (eg for ToolchainVersionOperator)

DEFAULT: None

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(, self.version) Versions only, no suffix.

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

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

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)

PARAMETER DESCRIPTION
begin_end

boolean, create a regex with begin/end match

DEFAULT: True