How to use the packaging.version function in packaging

To help you get started, we’ve selected a few packaging examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github circleguard / circleguard / circleguard / View on Github external
def overwrite_outdated_settings():
    last_version = version.parse(get_setting("last_version"))
    last_version = version.parse(last_version.base_version) # remove dev stuff
    for ver, changed_arr in FORCE_UPDATE.items():
        if last_version < version.parse(ver):
            for setting in changed_arr:
                if setting not in TYPES:
                    # happens if the key is in FORCE_UPDATE but was deleted in a
                    # later version, like message_cheater_found.
                set_setting(setting, DEFAULTS[TYPES[setting][1]][setting])
    set_setting("last_version", __version__)
github jazzband-roadies / website / jazzband / projects / View on Github external
def _validate_pep440_version(form, field):
    parsed = version.parse(

    # Check that this version is a valid PEP 440 version at all.
    if not isinstance(parsed, version.Version):
        raise validators.ValidationError(
            "Must start and end with a letter or numeral and contain only "
            "ascii numeric and '.', '_' and '-'."

    # Check that this version does not have a PEP 440 local segment attached
    # to it.
    if parsed.local is not None:
        raise validators.ValidationError("Cannot use PEP 440 local versions.")
github pymedphys / pymedphys / pymedphys / _dicom / View on Github external
def __eq__(self, other):
        if version.parse(pydicom.__version__) <= version.parse("1.2.1"):
            self_elems = sorted(list(self.dataset.iterall()), key=lambda x: x.tag)
            other_elems = sorted(list(other.dataset.iterall()), key=lambda x: x.tag)
            return self_elems == other_elems

        # TODO: Change for pydicom>=1.2.2?
        self_elems = sorted(list(self.dataset.iterall()), key=lambda x: x.tag)
        other_elems = sorted(list(other.dataset.iterall()), key=lambda x: x.tag)
        return self_elems == other_elems
github AruniRC / detectron-self-train / lib / core / View on Github external
values that are necessary (e.g., merging a config from a file, merging
    command line config options, etc.). By default, this function will also
    mark the global cfg as immutable to prevent changing the global cfg settings
    during script execution (which can lead to hard to debug errors or code
    that's harder to understand than is necessary).
        __C.RPN.RPN_ON = True
            "Path to the weight file must not be empty to load imagenet pertrained resnets."
        __C.MODEL.SHARE_RES5 = True
    if version.parse(torch.__version__) < version.parse('0.4.0'):
        __C.PYTORCH_VERSION_LESS_THAN_040 = True
        # create alias for PyTorch version less than 0.4.0
        init.uniform_ = init.uniform
        init.normal_ = init.normal
        init.constant_ = init.constant
        nn.GroupNorm = mynn.GroupNorm
    if make_immutable:
github pierky / arouteserver / pierky / arouteserver / View on Github external
That's why this function takes both `member` and `vlan_ip_info` into account.

            It's called from two other functions:
            - first time by process_member, at member level only, in order to catch
              route servers on versions <= 0.6.
            - second time, it's called by process_connection, to perform the check
              at connection level (VLAN IP info), to catch route servers on versions
              >= 0.7.

            schema_version = self._get_item("version", self.raw_data, str)

            # Until version 0.6, route servers were identified using a
            # specific `member_type`.
            if version.parse(schema_version) <= version.parse("0.6"):
                if self._get_item("member_type", member, str, True) == "routeserver":
                    return True
                return False

            # In version 0.7, "routeserver" was removed from the valid
            # values of `member_type`, and `service_type` was introduced, but at connection
            # level this time (VLAN IP info).
            if version.parse(schema_version) <= version.parse("0.7"):
                if vlan_ip_info:
                    service_type = self._get_item("service_type", vlan_ip_info, list, True)
                    if service_type and "ixrouteserver" in service_type:
                        return True
                return False

            # In the latest version (1.0 ATOW), the classification is still done
            # at connection level, but using a different attribute, `services`.
github voxel51 / eta / eta / core / View on Github external
        pkg_str = package_name

        pkg = importlib.import_module(package_name)
    except ImportError as e:
                "The requested operation requires that '%s' is installed on "
                "your machine" % pkg_str

    if has_min_ver or has_max_ver:
        pkg_version = packaging.version.parse(pkg.__version__)

        if (has_min_ver and pkg_version < min_version) or (
            has_max_ver and pkg_version >= max_version
            raise ImportError(
                "The requested operation requires that '%s' is installed "
                "on your machine; found '%s==%s'"
                % (pkg_str, package_name, pkg_version)
github dagster-io / dagster / bin / View on Github external
def check_new_version(new_version):
    parsed_version = packaging.version.parse(new_version)
    module_versions = check_existing_version()
    errors = {}
    last_version = None
    for module_name, module_version in module_versions.items():
        last_version = module_version
        if packaging.version.parse(module_version['__version__']) >= parsed_version:
            errors[module_name] = module_version['__version__']
    if errors:
        raise Exception(
            'Bailing: Found modules with existing versions greater than or equal to the new '
            'version {new_version}:\n{versions}'.format(
                new_version=new_version, versions=format_module_versions(module_versions)

    if not (
github kiibohd / kll / kll / common / View on Github external
if apply_offsets:
                            assert (len(self.min_scan_code) > self.most_recent_connect_id)
                            assert (len(self.max_scan_code) > self.most_recent_connect_id)
                            assert (len(self.interconnect_scancode_offsets) > self.most_recent_connect_id)

                    if (
                        l_element.value == "KLL"
                        mid_element.value == "="
                        # Rebuild version number
                        file_version = ".".join([token.value for token in tokens[2:]])

                        # Compare version to last compatible version (not running version, this is different)
                        if version.parse(file_version) < version.parse(self.control.last_compat_version):
                                "{} {}".format(
                            print("      Contains possibly incompatible KLL expressions from \033[1m{}\033[0m".format(
                            print("      Please your configuration to KLL {} compliant code".format(
                            info = suggestions.Suggestions(self.control.short_version, file_version)
github rodluger / starry / .ci / View on Github external
import starry
import packaging
import urllib

# Hack to figure out if we are the latest version
url = ""
all_versions = []
for line in urllib.request.urlopen(url):
    version_string = line.decode("utf-8").replace("\n", "").strip()
all_versions = sorted(all_versions)
current_version = packaging.version.parse(starry.__version__)
is_latest = (current_version.is_devrelease) and (
    current_version.base_version >= all_versions[-1].base_version

if is_latest: