From b44c80835888f29962c70ad5665f4b1427cdf1d4 Mon Sep 17 00:00:00 2001 From: Tomas Orsava Date: Wed, 10 Mar 2021 19:51:55 +0100 Subject: [PATCH] pythondistdeps.py: Compare extras as lowercase - New test sources tarball with added test data --- .gitignore | 1 + pythondistdeps.py | 20 +++++++++++ sources | 2 +- .../scripts_pythondistdeps/test-data.yaml | 34 +++++++++++++++++++ .../scripts_pythondistdeps/test-requires.yaml | 5 +++ update-test-sources.sh | 1 + 6 files changed, 62 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 71b8b4c..e525b8a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /test-sources-2020-04-29.tar.gz /tests/__pycache__/ /tests/data/scripts_pythondistdeps/usr/ +/test-sources-2021-03-11.tar.gz diff --git a/pythondistdeps.py b/pythondistdeps.py index 9ba0590..b097228 100755 --- a/pythondistdeps.py +++ b/pythondistdeps.py @@ -21,6 +21,26 @@ from warnings import warn from packaging.requirements import Requirement as Requirement_ from packaging.version import parse +import packaging.markers + +# Monkey patching packaging.markers to handle extras names in a +# case-insensitive manner: +# pip considers dnspython[DNSSEC] and dnspython[dnssec] to be equal, but +# packaging markers treat extras in a case-sensitive manner. To solve this +# issue, we introduce a comparison operator that compares case-insensitively +# if both sides of the comparison are strings. And then we inject this +# operator into packaging.markers to be used when comparing names of extras. +# Fedora BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1936875 +# Upstream issue: https://discuss.python.org/t/what-extras-names-are-treated-as-equal-and-why/7614 +# - After it's established upstream what is the canonical form of an extras +# name, we plan to open an issue with packaging to hopefully solve this +# there without having to resort to monkeypatching. +def str_lower_eq(a, b): + if isinstance(a, str) and isinstance(b, str): + return a.lower() == b.lower() + else: + return a == b +packaging.markers._operators["=="] = str_lower_eq try: from importlib.metadata import PathDistribution diff --git a/sources b/sources index 1d7f97a..d8fedb8 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (test-sources-2020-04-29.tar.gz) = a5539fbe05a4f7128b4f82e960c3f1392a55ad53086dfd7fbc436d2743feaf64784e08667237baed3a32f149db25bc63e4ab3efc2b0270f969c59550b75102b1 +SHA512 (test-sources-2021-03-11.tar.gz) = 6f34c8151625be489a6a4d56d1fd3d39b7908bd31402c9703cb65918385320dfad35f35a32920c816fb85a829f44aaf04dc1d0654ccf512e26e87e95dbf87430 diff --git a/tests/data/scripts_pythondistdeps/test-data.yaml b/tests/data/scripts_pythondistdeps/test-data.yaml index 4a611c3..6dc4612 100644 --- a/tests/data/scripts_pythondistdeps/test-data.yaml +++ b/tests/data/scripts_pythondistdeps/test-data.yaml @@ -1118,6 +1118,40 @@ python3dist(backports-range) = 3.7.2 python3dist(backports.range) = 3.7.2 requires: python(abi) = 3.7 +--requires --normalized-names-format pep503 --package-name python3-dns+DNSSEC: + --provides --majorver-provides --normalized-names-format pep503 --package-name python3-dns+DNSSEC: + usr/lib/python3.9/site-packages/dnspython-2.1.0-py3.9.egg-info: + provides: |- + python3.9dist(dnspython[dnssec]) = 2.1 + python3dist(dnspython[dnssec]) = 2.1 + requires: |- + python(abi) = 3.9 + python3.9dist(cryptography) >= 2.6 +--requires --normalized-names-format pep503 --package-name python3-dns+Dnssec: + --provides --majorver-provides --normalized-names-format pep503 --package-name python3-dns+Dnssec: + usr/lib/python3.9/site-packages/dnspython-2.1.0-py3.9.egg-info: + provides: |- + python3.9dist(dnspython[dnssec]) = 2.1 + python3dist(dnspython[dnssec]) = 2.1 + requires: |- + python(abi) = 3.9 + python3.9dist(cryptography) >= 2.6 +--requires --normalized-names-format pep503 --package-name python3-dns+dnssec: + --provides --majorver-provides --normalized-names-format pep503 --package-name python3-dns+dnssec: + usr/lib/python3.9/site-packages/dnspython-2.1.0-py3.9.egg-info: + provides: |- + python3.9dist(dnspython[dnssec]) = 2.1 + python3dist(dnspython[dnssec]) = 2.1 + requires: |- + python(abi) = 3.9 + python3.9dist(cryptography) >= 2.6 + usr/lib/python3.9/site-packages/dnspython-2.1.0.dist-info: + provides: |- + python3.9dist(dnspython[dnssec]) = 2.1 + python3dist(dnspython[dnssec]) = 2.1 + requires: |- + python(abi) = 3.9 + python3.9dist(cryptography) >= 2.6 --requires --normalized-names-format pep503 --package-name python3-setuptools+certs: --provides --majorver-provides --normalized-names-format pep503 --package-name python3-setuptools+certs: usr/lib/python3.9/site-packages/setuptools-41.6.0.dist-info: diff --git a/tests/data/scripts_pythondistdeps/test-requires.yaml b/tests/data/scripts_pythondistdeps/test-requires.yaml index c06d6c0..32d70f2 100644 --- a/tests/data/scripts_pythondistdeps/test-requires.yaml +++ b/tests/data/scripts_pythondistdeps/test-requires.yaml @@ -95,3 +95,8 @@ fsleyes: taskotron-python-versions: wheel: '0.1.dev6': ['3.9'] +dnspython: + sdist: + '2.1.0': ['3.9'] + wheel: + '2.1.0': ['3.9'] diff --git a/update-test-sources.sh b/update-test-sources.sh index b7fa68b..4d7963e 100755 --- a/update-test-sources.sh +++ b/update-test-sources.sh @@ -3,6 +3,7 @@ # # Requirements: # - pip >= 20.0.1 +# - poetry # Due to bug: https://github.com/pypa/pip/issues/9701 # # First prune old test data