clearml_agent/helper/package/requirements.py
def compare_versions(cls, version_a, op, version_b, ignore_sub_versions=True, num_parts=3):
        """
        Compare two versions based on the op operator
        returns bool(version_a op version_b)
        Notice: Ignores a/b/rc/post/dev markers on the version

        :param str version_a:
        :param str op: '==', '===', '>', '>=', '<=', '<', '~='
        :param str version_b:
        :param bool ignore_sub_versions: if true compare only major.minor.patch
            (ignore a/b/rc/post/dev in the comparison)
        :param int num_parts: number of parts to compare, split by . (dot)
        :return bool: version_a op version_b
        """

        if not version_b:
            return True

        if not num_parts:
            num_parts = max(len(version_a.split('.')), len(version_b.split('.')), )

        if op == '~=':
            num_parts = len(version_b.split('.')) - 1
            num_parts = max(num_parts, 2)
            op = '=='
            ignore_sub_versions = True
        elif op == '===':
            op = '=='

        try:
            version_a_key = cls._get_match_key(cls._regex.search(version_a), num_parts, ignore_sub_versions)
            version_b_key = cls._get_match_key(cls._regex.search(version_b), num_parts, ignore_sub_versions)
        except:
            # revert to string based
            for v in cls._sub_versions_pep440:
                version_a = version_a.replace(v, '.')
                version_b = version_b.replace(v, '.')

            version_a = (version_a.strip('.').split('.') + ['0'] * num_parts)[:num_parts]
            version_b = (version_b.strip('.').split('.') + ['0'] * num_parts)[:num_parts]
            version_a_key = ''
            version_b_key = ''
            for i in range(num_parts):
                pad = '{:0>%d}.' % max([9, 1 + len(version_a[i]), 1 + len(version_b[i])])
                version_a_key += pad.format(version_a[i])
                version_b_key += pad.format(version_b[i])

        if op == '==':
            return version_a_key == version_b_key
        if op == '<=':
            return version_a_key <= version_b_key
        if op == '>=':
            return version_a_key >= version_b_key
        if op == '>':
            return version_a_key > version_b_key
        if op == '<':
            return version_a_key < version_b_key
        raise ValueError('Unrecognized comparison operator [{}]'.format(op))

        Compare two versions based on the op operator
        returns bool(version_a op version_b)
        Notice: Ignores a/b/rc/post/dev markers on the version

        :param str version_a:
        :param str op: '==', '===', '>', '>=', '<=', '<', '~='
        :param str version_b:
        :param bool ignore_sub_versions: if true compare only major.minor.patch
            (ignore a/b/rc/post/dev in the comparison)
        :param int num_parts: number of parts to compare, split by . (dot)
        :return bool: version_a op version_b
        
Compare two versions based on the op operator
returns bool(version_a op version_b)
Notice: Ignores a/b/rc/post/dev markers on the version
Compare two versions based on the op operator returns bool ( version_a op version_b ) Notice : Ignores a / b / rc / post / dev markers on the version
def compare_versions(cls, version_a, op, version_b, ignore_sub_versions=True, num_parts=3):
        if not version_b:
            return True
        if not num_parts:
            num_parts = max(len(version_a.split('.')), len(version_b.split('.')), )
        if op == '~=':
            num_parts = len(version_b.split('.')) - 1
            num_parts = max(num_parts, 2)
            op = '=='
            ignore_sub_versions = True
        elif op == '===':
            op = '=='
        try:
            version_a_key = cls._get_match_key(cls._regex.search(version_a), num_parts, ignore_sub_versions)
            version_b_key = cls._get_match_key(cls._regex.search(version_b), num_parts, ignore_sub_versions)
        except:
            for v in cls._sub_versions_pep440:
                version_a = version_a.replace(v, '.')
                version_b = version_b.replace(v, '.')
            version_a = (version_a.strip('.').split('.') + ['0'] * num_parts)[:num_parts]
            version_b = (version_b.strip('.').split('.') + ['0'] * num_parts)[:num_parts]
            version_a_key = ''
            version_b_key = ''
            for i in range(num_parts):
                pad = '{:0>%d}.' % max([9, 1 + len(version_a[i]), 1 + len(version_b[i])])
                version_a_key += pad.format(version_a[i])
                version_b_key += pad.format(version_b[i])
        if op == '==':
            return version_a_key == version_b_key
        if op == '<=':
            return version_a_key <= version_b_key
        if op == '>=':
            return version_a_key >= version_b_key
        if op == '>':
            return version_a_key > version_b_key
        if op == '<':
            return version_a_key < version_b_key
        raise ValueError('Unrecognized comparison operator [{}]'.format(op))
def compare_versions ( cls , version_a , op , version_b , ignore_sub_versions = True , num_parts = 3 ) : if not version_b : return True if not num_parts : num_parts = max ( len ( version_a . split ( '.' ) ) , len ( version_b . split ( '.' ) ) , ) if op == '~=' : num_parts = len ( version_b . split ( '.' ) ) - 1 num_parts = max ( num_parts , 2 ) op = '==' ignore_sub_versions = True elif op == '===' : op = '==' try : version_a_key = cls . _get_match_key ( cls . _regex . search ( version_a ) , num_parts , ignore_sub_versions ) version_b_key = cls . _get_match_key ( cls . _regex . search ( version_b ) , num_parts , ignore_sub_versions ) except : for v in cls . _sub_versions_pep440 : version_a = version_a . replace ( v , '.' ) version_b = version_b . replace ( v , '.' ) version_a = ( version_a . strip ( '.' ) . split ( '.' ) + [ '0' ] * num_parts ) [ : num_parts ] version_b = ( version_b . strip ( '.' ) . split ( '.' ) + [ '0' ] * num_parts ) [ : num_parts ] version_a_key = '' version_b_key = '' for i in range ( num_parts ) : pad = '{:0>%d}.' % max ( [ 9 , 1 + len ( version_a [ i ] ) , 1 + len ( version_b [ i ] ) ] ) version_a_key += pad . format ( version_a [ i ] ) version_b_key += pad . format ( version_b [ i ] ) if op == '==' : return version_a_key == version_b_key if op == '<=' : return version_a_key <= version_b_key if op == '>=' : return version_a_key >= version_b_key if op == '>' : return version_a_key > version_b_key if op == '<' : return version_a_key < version_b_key raise ValueError ( 'Unrecognized comparison operator [{}]' . format ( op ) )
Compare two versions based on the op operator
returns bool(version_a op version_b)
Notice: Ignores a/b/rc/post/dev markers on the version
Compare two versions based on the op operator returns bool ( version_a op version_b ) Notice : Ignores a / b / rc / post / dev markers on the version
"""
        Compare two versions based on the op operator
        returns bool(version_a op version_b)
        Notice: Ignores a/b/rc/post/dev markers on the version

        :param str version_a:
        :param str op: '==', '===', '>', '>=', '<=', '<', '~='
        :param str version_b:
        :param bool ignore_sub_versions: if true compare only major.minor.patch
            (ignore a/b/rc/post/dev in the comparison)
        :param int num_parts: number of parts to compare, split by . (dot)
        :return bool: version_a op version_b
        """ # revert to string based
version_a op version_b
version_a op version_b
bool
cls
version_a
None
op
None
version_b
None
ignore_sub_versions
if true compare only major.minor.patch
(ignore a/b/rc/post/dev in the comparison)
if true compare only major . minor . patch ( ignore a / b / rc / post / dev in the comparison )
num_parts
number of parts to compare, split by . (dot)
number of parts to compare split by . ( dot )