How to use the packaging.version.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 pypa / packaging / tests / test_version.py View on Github external
def test_version_base_version(self, version, base_version):
        assert Version(version).base_version == base_version
github datastax / python-driver / tests / integration / __init__.py View on Github external
}
                    })
                if 'spark' in workloads:
                    if Version(dse_version) >= Version('6.8'):
                        config_options = {
                            "resource_manager_options": {
                                "worker_options": {
                                    "cores_total": 0.1,
                                    "memory_total": "64M"
                                }
                            }
                        }
                    else:
                        config_options = {"initial_spark_worker_resources": 0.1}

                    if Version(dse_version) >= Version('6.7'):
                        log.debug("Disabling AlwaysON SQL for a DSE 6.7 Cluster")
                        config_options['alwayson_sql_options'] = {'enabled': False}
                    CCM_CLUSTER.set_dse_configuration_options(config_options)
                common.switch_cluster(path, cluster_name)
                CCM_CLUSTER.set_configuration_options(configuration_options)
                CCM_CLUSTER.populate(nodes, ipformat=ipformat)

                CCM_CLUSTER.set_dse_configuration_options(dse_options)
            else:
                CCM_CLUSTER = CCMCluster(path, cluster_name, **ccm_options)
                CCM_CLUSTER.set_configuration_options({'start_native_transport': True})
                if Version(cassandra_version) >= Version('2.2'):
                    CCM_CLUSTER.set_configuration_options({'enable_user_defined_functions': True})
                    if Version(cassandra_version) >= Version('3.0'):
                        CCM_CLUSTER.set_configuration_options({'enable_scripted_user_defined_functions': True})
                        if Version(cassandra_version) >= Version('4.0-a'):
github datastax / python-driver / tests / integration / advanced / graph / test_graph_query.py View on Github external
self.assertEqual(len(v.properties['mult_key']), 2)
        self.assertEqual(v.properties['mult_key'][0].label, 'mult_key')
        self.assertEqual(v.properties['mult_key'][1].label, 'mult_key')
        self.assertEqual(v.properties['mult_key'][0].value, 'value0')
        self.assertEqual(v.properties['mult_key'][1].value, 'value1')

        # single_with_one_value
        v = self.execute_graph('''v = graph.addVertex('SW1')
                             v.property('single_key', 'value')
                             v''', graphson)[0]
        self.assertEqual(len(v.properties), 1)
        self.assertEqual(len(v.properties['single_key']), 1)
        self.assertEqual(v.properties['single_key'][0].label, 'single_key')
        self.assertEqual(v.properties['single_key'][0].value, 'value')

        if DSE_VERSION < Version('6.8'):
            # single_with_two_values
            with self.assertRaises(InvalidRequest):
                v = self.execute_graph('''
                    v = graph.addVertex('SW1')
                    v.property('single_key', 'value0').property('single_key', 'value1').next()
                    v
                ''', graphson)[0]
        else:
            # >=6.8 single_with_two_values, first one wins
            v = self.execute_graph('''v = graph.addVertex('SW1')
                v.property('single_key', 'value0').property('single_key', 'value1')
                v''', graphson)[0]
            self.assertEqual(v.properties['single_key'][0].value, 'value0')
github datastax / python-driver / tests / integration / advanced / graph / fluent / __init__.py View on Github external
def __test_udt(self, schema, graphson, address_class, address_with_tags_class,
                   complex_address_class, complex_address_with_owners_class):
        if schema is not CoreGraphSchema or DSE_VERSION < Version('6.8'):
            raise unittest.SkipTest("Graph UDT is only supported with DSE 6.8+ and Core graphs.")

        ep = self.get_execution_profile(graphson)

        Address = address_class
        AddressWithTags = address_with_tags_class
        ComplexAddress = complex_address_class
        ComplexAddressWithOwners = complex_address_with_owners_class

        # setup udt
        self.session.execute_graph("""
                schema.type('address').property('address', Text).property('city', Text).property('state', Text).create();
                schema.type('addressTags').property('address', Text).property('city', Text).property('state', Text).
                    property('tags', setOf(Text)).create();
                schema.type('complexAddress').property('address', Text).property('address_tags', frozen(typeOf('addressTags'))).
                    property('city', Text).property('state', Text).property('props', mapOf(Text, Int)).create();
github fortinet-solutions-cse / fortiosapi / tests / test_fortiosapi_virsh.py View on Github external
def test_is_license_valid(self):
        if Version(fgt.get_version()) > Version('5.6'):
            self.assertTrue(fgt.license()['results']['vm']['status'] == "vm_valid" or "vm_eval")
        else:
            self.assertTrue(True, "not supported before 5.6")
github axiom-data-science / feedstockrot / feedstockrot / package_sources / source.py View on Github external
def versions(self) -> Set[Version]:
        if self._versions is not None:
            return self._versions
        if self._data_versions is None:
            return None

        versions = set()
        for version_str in self._data_versions:
            try:
                version = Version(version_str)
            except InvalidVersion:
                logging.info("Got invalid version for {}: {}".format(self.package.get_name(), version_str))
                continue
            versions.add(version)

        self._versions = versions
        return self._versions
github alexbecker / dotlock / src / dotlock / dist_info / simple_api.py View on Github external
if filename.endswith('.whl'):
                package_type = PackageType.bdist_wheel
                if not is_supported(filename):
                    logger.debug('Skipping unsupported bdist %s', filename)
                    continue

                version = get_wheel_version(filename)
            else:
                package_type = PackageType.sdist

                parsed_filename = _SDIST_FILENAME_RE.match(filename)
                if not parsed_filename:
                    logging.debug(f'Skipping unrecognized filename {filename}')
                    continue

                version = Version(parsed_filename.group('ver'))
        except InvalidVersion:
            logger.debug('Skipping invalid version for file %s', filename)
            continue

        candidate_infos.append(CandidateInfo(
            name=name,
            package_type=package_type,
            version=version,
            source=source,
            location=urldefrag(candidate_url.geturl()).url,  # Strip [hash_alg]= fragment.
            hash_alg=hash_alg,
            hash_val=hash_val,
        ))

    return candidate_infos
github technologiescollege / Blockly-at-rduino / supervision / s2aio / Lib / site-packages / pkg_resources / __init__.py View on Github external
def safe_version(version):
    """
    Convert an arbitrary string to a standard version string
    """
    try:
        # normalize the version
        return str(packaging.version.Version(version))
    except packaging.version.InvalidVersion:
        version = version.replace(' ','.')
        return re.sub('[^A-Za-z0-9.]+', '-', version)
github dephell / dephell / dephell / pythons.py View on Github external
non_abstract = type(self)(abstract=False)
        for version in PYTHONS:
            python = non_abstract.get_by_version(Version(version))
            if python is not None:
                returned.add(version)
                yield python

        # return abstract pythons for all python versions not in this system
        for version in PYTHONS:
            if version in returned:
                continue
            path = self.current.path
            name = 'python' + version
            yield Python(
                path=path.parent / (name + path.suffix),
                version=Version(version),
                name=name,
                implementation=self.current.implementation,
                abstract=True,
            )
github opencord / voltha-openolt-adapter / python / adapters / openolt / main.py View on Github external
def get_version(self):
        path = defs['version_file']
        if not path.startswith('/'):
            dir = os.path.dirname(os.path.abspath(__file__))
            path = os.path.join(dir, path)

        path = os.path.abspath(path)
        version_file = open(path, 'r')
        v = version_file.read()

        # Use Version to validate the version string - exception will be raised
        # if the version is invalid
        Version(v)

        version_file.close()
        return v