Skip to content

Commit

Permalink
Merge pull request #109 from swastkk/packvers-added
Browse files Browse the repository at this point in the history
Replace packaging with packvers #108
  • Loading branch information
pombredanne authored Jan 13, 2023
2 parents 4f617da + 6579412 commit e1ffca1
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 36 deletions.
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ 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

packvers >= 21.5
[options.packages.find]
where = src

Expand Down
12 changes: 5 additions & 7 deletions src/_packagedcode/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
from _packagedcode import models
from _packagedcode.utils import build_description
from _packagedcode.utils import combine_expressions
Expand Down
2 changes: 1 addition & 1 deletion src/python_inspector/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/python_inspector/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/python_inspector/resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion src/python_inspector/setup_py_live_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 6 additions & 6 deletions src/python_inspector/utils_pip_compatibility_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+)_(.+)")

Expand Down
6 changes: 3 additions & 3 deletions src/python_inspector/utils_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions tests/test_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -156,23 +156,23 @@ 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"
assert is_valid_version(parsed_version, requirements, identifier, bad_versions)


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"
assert is_valid_version(parsed_version, requirements, identifier, bad_versions)


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"
Expand Down

0 comments on commit e1ffca1

Please sign in to comment.