diff --git a/requirements.txt b/requirements.txt index 1f953e2f..f763956b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,13 +5,14 @@ charset-normalizer==2.1.0 click==8.1.3 colorama==0.4.5 commoncode==30.2.0 -dparse2==0.6.1 +dparse2==0.7.0 idna==3.3 importlib-metadata==4.12.0 intbitset==3.0.1 packageurl-python==0.10.0 packaging==21.3 -pip-requirements-parser==31.2.0 +packvers==21.5 +pip-requirements-parser==32.0.1 pkginfo2==30.0.0 pyparsing==3.0.9 PyYAML==6.0 diff --git a/setup.cfg b/setup.cfg index 73d7b7e6..04e3412b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -58,18 +58,19 @@ install_requires = click > 7.0 colorama >= 0.3.9 commoncode >= 30.0.0 - dparse2 >= 0.6.1 + dparse2 >= 0.7.0 importlib_metadata >= 4.12.0 packageurl_python >= 0.9.0 pkginfo2 >= 30.0.0 - pip-requirements-parser >= 31.2.0 + pip-requirements-parser >= 32.0.1 requests >= 2.18.0 resolvelib >= 0.8.1 saneyaml >= 0.5.2 tinynetrc >= 1.3.1 toml >= 0.10.0 mock >= 3.0.5 - + packaging >= 21.0.0 + packvers >= 21.5 [options.packages.find] where = src diff --git a/src/_packagedcode/pypi.py b/src/_packagedcode/pypi.py index a76b6f8d..b6dc3e91 100644 --- a/src/_packagedcode/pypi.py +++ b/src/_packagedcode/pypi.py @@ -20,18 +20,16 @@ from typing import NamedTuple import tempfile import zipfile - import dparse2 -import packaging +import packvers as packaging import pip_requirements_parser -import pkginfo2 from commoncode import fileutils -from packaging.specifiers import SpecifierSet +from packvers.specifiers import SpecifierSet from packageurl import PackageURL -from packaging import markers -from packaging.requirements import Requirement -from packaging.utils import canonicalize_name - +from packvers import markers +from packvers.requirements import Requirement +from packvers.utils import canonicalize_name +import pkginfo2 from _packagedcode import models from _packagedcode.utils import build_description from _packagedcode.utils import combine_expressions diff --git a/src/python_inspector/api.py b/src/python_inspector/api.py index 42711568..f4278b6f 100644 --- a/src/python_inspector/api.py +++ b/src/python_inspector/api.py @@ -16,7 +16,7 @@ from typing import Sequence from packageurl import PackageURL -from packaging.requirements import Requirement +from packvers.requirements import Requirement from resolvelib import BaseReporter from resolvelib import Resolver from tinynetrc import Netrc diff --git a/src/python_inspector/dependencies.py b/src/python_inspector/dependencies.py index 7ba7fcb6..a7aec863 100644 --- a/src/python_inspector/dependencies.py +++ b/src/python_inspector/dependencies.py @@ -10,7 +10,7 @@ # from packageurl import PackageURL -from packaging.requirements import Requirement +from packvers.requirements import Requirement from pip_requirements_parser import InstallRequirement from _packagedcode import models diff --git a/src/python_inspector/resolution.py b/src/python_inspector/resolution.py index 8c0016c6..c86f7a8a 100644 --- a/src/python_inspector/resolution.py +++ b/src/python_inspector/resolution.py @@ -18,12 +18,12 @@ from typing import Union from zipfile import ZipFile -import packaging.utils +import packvers.utils from packageurl import PackageURL -from packaging.requirements import Requirement -from packaging.version import LegacyVersion -from packaging.version import Version -from packaging.version import parse as parse_version +from packvers.requirements import Requirement +from packvers.version import LegacyVersion +from packvers.version import Version +from packvers.version import parse as parse_version from resolvelib import AbstractProvider from resolvelib.structs import DirectedGraph @@ -325,7 +325,7 @@ def __init__( def identify(self, requirement_or_candidate: Union[Candidate, Requirement]) -> str: """Given a requirement, return an identifier for it. Overridden.""" - name = packaging.utils.canonicalize_name(requirement_or_candidate.name) + name = packvers.utils.canonicalize_name(requirement_or_candidate.name) if requirement_or_candidate.extras: extras_str = ",".join(sorted(requirement_or_candidate.extras)) return "{}[{}]".format(name, extras_str) @@ -576,7 +576,7 @@ def _iter_dependencies(self, candidate: Candidate) -> Generator[Requirement, Non """ Yield dependencies for the given candidate. """ - name = packaging.utils.canonicalize_name(candidate.name) + name = packvers.utils.canonicalize_name(candidate.name) # TODO: handle extras https://github.com/nexB/python-inspector/issues/10 if candidate.extras: r = f"{name}=={candidate.version}" diff --git a/src/python_inspector/setup_py_live_eval.py b/src/python_inspector/setup_py_live_eval.py index 129cc185..e9515e55 100755 --- a/src/python_inspector/setup_py_live_eval.py +++ b/src/python_inspector/setup_py_live_eval.py @@ -21,7 +21,7 @@ import mock import setuptools from commoncode.command import pushd -from packaging.requirements import Requirement +from packvers.requirements import Requirement def minver_error(pkg_name): diff --git a/src/python_inspector/utils_pip_compatibility_tags.py b/src/python_inspector/utils_pip_compatibility_tags.py index 122ae59a..afe3fb3b 100644 --- a/src/python_inspector/utils_pip_compatibility_tags.py +++ b/src/python_inspector/utils_pip_compatibility_tags.py @@ -27,12 +27,12 @@ import re -from packaging.tags import compatible_tags -from packaging.tags import cpython_tags -from packaging.tags import generic_tags -from packaging.tags import interpreter_name -from packaging.tags import interpreter_version -from packaging.tags import mac_platforms +from packvers.tags import compatible_tags +from packvers.tags import cpython_tags +from packvers.tags import generic_tags +from packvers.tags import interpreter_name +from packvers.tags import interpreter_version +from packvers.tags import mac_platforms _osx_arch_pat = re.compile(r"(.+)_(\d+)_(\d+)_(.+)") diff --git a/src/python_inspector/utils_pypi.py b/src/python_inspector/utils_pypi.py index 7b30525d..f7e21d1a 100644 --- a/src/python_inspector/utils_pypi.py +++ b/src/python_inspector/utils_pypi.py @@ -26,9 +26,9 @@ from bs4 import BeautifulSoup from commoncode import fileutils from commoncode.hash import multi_checksums -from packaging import tags as packaging_tags -from packaging import version as packaging_version -from packaging.specifiers import SpecifierSet +from packvers import tags as packaging_tags +from packvers import version as packaging_version +from packvers.specifiers import SpecifierSet from python_inspector import DEFAULT_PYTHON_VERSION from python_inspector import utils_pip_compatibility_tags diff --git a/tests/test_resolution.py b/tests/test_resolution.py index d470b084..3e430906 100644 --- a/tests/test_resolution.py +++ b/tests/test_resolution.py @@ -11,10 +11,10 @@ import os from unittest.mock import patch -import packaging +import packvers import pytest from commoncode.testcase import FileDrivenTesting -from packaging.requirements import Requirement +from packvers.requirements import Requirement from _packagedcode import models from python_inspector.api import get_resolved_dependencies @@ -156,7 +156,7 @@ def test_without_supported_wheels(): def test_is_valid_version(): - parsed_version = packaging.version.parse("2.1.2") + parsed_version = packvers.version.parse("2.1.2") requirements = {"flask": [Requirement("flask>2.0.0")]} bad_versions = [] identifier = "flask" @@ -164,7 +164,7 @@ def test_is_valid_version(): def test_is_valid_version_with_no_specifier(): - parsed_version = packaging.version.parse("2.1.2") + parsed_version = packvers.version.parse("2.1.2") requirements = {"flask": [Requirement("flask")]} bad_versions = [] identifier = "flask" @@ -172,7 +172,7 @@ def test_is_valid_version_with_no_specifier(): def test_is_valid_version_with_no_specifier_and_pre_release(): - parsed_version = packaging.version.parse("1.0.0b4") + parsed_version = packvers.version.parse("1.0.0b4") requirements = {"flask": [Requirement("flask")]} bad_versions = [] identifier = "flask"