def complex_semver_match(version, version_specifier):
    """
    Custom semver match function which also supports complex semver specifiers
    such as >=1.6, <2.0, etc.

    NOTE: This function also supports special "all" version specifier. When "all"
    is specified, any version provided will be considered valid.

    :rtype: ``bool``
    """
    if version_specifier == "all":
        return True

    split_version_specifier = version_specifier.split(",")

    if len(split_version_specifier) == 1:
        # No comma, we can do a simple comparision
        return semver.Version.parse(version).match(version_specifier)
    else:
        # Compare part by part
        for version_specifier_part in split_version_specifier:
            version_specifier_part = version_specifier_part.strip()

            if not version_specifier_part:
                continue

            if not semver.Version.parse(version).match(version_specifier_part):
                return False

        return True

    Custom semver match function which also supports complex semver specifiers
    such as >=1.6, <2.0, etc.

    NOTE: This function also supports special "all" version specifier. When "all"
    is specified, any version provided will be considered valid.

    :rtype: ``bool``
    
st2common/st2common/util/versioning.py