How to use the packaging.version.LegacyVersion 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_specifiers.py View on Github external
def test_specifier_explicit_legacy(self):
        assert Specifier("==1.0").contains(LegacyVersion("1.0"))
github pypa / packaging / tests / test_version.py View on Github external
def test_legacy_version_public(self, version):
        assert LegacyVersion(version).public == version
github pypa / packaging / tests / test_version.py View on Github external
def test_compare_other(self, op, expected):
        other = pretend.stub(**{"__{0}__".format(op): lambda other: NotImplemented})

        assert getattr(operator, op)(LegacyVersion("1"), other) is expected
github microsoft / sqldev / env / lib / python2.7 / site-packages / pkg_resources / __init__.py View on Github external
"you have another use case requiring the tuple, please file a "
            "bug with the setuptools project describing that need.",
            RuntimeWarning,
            stacklevel=1,
        )

        for part in old_parse_version(str(self)):
            yield part


class SetuptoolsVersion(_SetuptoolsVersionMixin, packaging.version.Version):
    pass


class SetuptoolsLegacyVersion(_SetuptoolsVersionMixin,
                              packaging.version.LegacyVersion):
    pass


def parse_version(v):
    try:
        return SetuptoolsVersion(v)
    except packaging.version.InvalidVersion:
        return SetuptoolsLegacyVersion(v)


_state_vars = {}


def _declare_state(vartype, **kw):
    globals().update(kw)
    _state_vars.update(dict.fromkeys(kw, vartype))
github deepmodeling / deepmd-kit / setup.py View on Github external
with open(readme_file) as f:
        readme = f.read()

try:
    tf_install_dir = imp.find_module('tensorflow')[1] 
except ImportError:
    site_packages_path = path.join(path.dirname(path.__file__), 'site-packages')
    tf_install_dir = imp.find_module('tensorflow', [site_packages_path])[1]

# install_requires = ['xml']
install_requires=['numpy', 'scipy']
setup_requires=['setuptools_scm']

# add cmake as a build requirement if cmake>3.0 is not installed
try:
    if LegacyVersion(get_cmake_version()) < LegacyVersion("3.0"):
        setup_requires.append('cmake')
except SKBuildError:
    setup_requires.append('cmake')

try:
    makedirs('deepmd')
except OSError:
    pass

setup(
    name="deepmd-kit",
    setup_requires=setup_requires,
    use_scm_version={'write_to': 'source/train/_version.py'},
    author="Han Wang",
    author_email="wang_han@iapcm.ac.cn",
    description="A deep learning package for many-body potential energy representation and molecular dynamics",
github AnyBlok / AnyBlok / anyblok / version.py View on Github external
def parse_other(self, other):
        if other is None:
            other = LegacyVersion('')
        elif not isinstance(other, (Version, LegacyVersion)):
            other = parse_version(other)

        return other
github supervisely / supervisely / agent / src / worker / task_dockerized.py View on Github external
agent_version = get_version(agent_image)
        plugin_version = get_version(plugin_image)

        if agent_version is None:
            self.logger.info('Unknown agent version')
            return

        if plugin_version is None:
            self.logger.info('Unknown plugin version')
            return

        av = version.parse(agent_version)
        pv = version.parse(plugin_version)

        if type(av) is version.LegacyVersion or type(pv) is version.LegacyVersion:
            self.logger.info('Invalid semantic version, can not compare')
            return

        if av.release[0] < pv.release[0]:
            self.logger.critical('Agent version is lower than plugin version. Please, update agent.')
github mozilla / mozdownload / mozdownload / scraper.py View on Github external
def query_versions(self, version=None):
        """Check specified version and resolve special values."""
        if version not in RELEASE_AND_CANDIDATE_LATEST_VERSIONS:
            return [version]

        url = urljoin(self.base_url, 'releases/')
        parser = self._create_directory_parser(url)
        if version:
            versions = parser.filter(RELEASE_AND_CANDIDATE_LATEST_VERSIONS[version])
            from packaging.version import LegacyVersion
            versions.sort(key=LegacyVersion)
            return [versions[-1]]
        else:
            return parser.entries
github pypa / packaging / packaging / specifiers.py View on Github external
def _coerce_version(self, version):
        # type: (Union[ParsedVersion, str]) -> LegacyVersion
        if not isinstance(version, LegacyVersion):
            version = LegacyVersion(str(version))
        return version