scripts/pythondistdeps: Backport switch to importlib.metadata from upstream

Upstream change to importlib.metadata: https://github.com/rpm-software-management/rpm/pull/1317

Due to extras packages being hadled slightly differently by importlib,
one test case for this was added.  And due to changes in handling
requires.txt files, comments were removed from the pyreq2rpm.tests
testing package.

Also because of the switch, we removed the dependency on setuptools and
added a dependency on packaging.

Note: Some packages with egg-info files might provide a different name
due to this change if there is a conflict between the filename and the
name in the metadata. Previously, the filename was sometimes used to
parse the name, now it is always the content of that file, which is what
packaging does, and thus also pip and other Python tooling. Currently,
this is known to affect only 1 package in Fedora (ntpsec).

The resulting script is different from upstream because of not yet upstreamed changes in Fedora:
- scripts/pythondistdeps: Rework error messages
- scripts/pythondistdeps: Add parameter --package-name
- scripts/pythondistdeps: Implement provides/requires for extras packages
- pythondistdeps.py: When parsing extras name, take the rightmost +

These changes are proposed in this upstream PR: https://github.com/rpm-software-management/rpm/pull/1546
This commit is contained in:
Tomas Orsava 2021-02-17 12:18:26 +01:00
commit 438d8d3b70
4 changed files with 165 additions and 119 deletions

View file

@ -1,4 +1,3 @@
# Taken from pyreq2rpm, removed tests that are expected to fail
foobar0~=2.4.8
foobar1~=2.4.8.0
foobar2~=2.4.8.1
@ -91,10 +90,8 @@ pyparsing0
pyparsing1>=2.0.1,!=2.0.4,!=2.1.2,!=2.1.6
babel>=1.3,!=2.0
# Tests for breakages in Fedora
fedora-python-nb2plots==0+unknown
# Other tests
hugo1==1.0.0.dev7
hugo2<=8a4
hugo3!=11.1.1b14

View file

@ -1216,6 +1216,15 @@
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-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:
provides: |-
python3.9dist(setuptools[certs]) = 41.6
python3dist(setuptools[certs]) = 41.6
requires: |-
python(abi) = 3.9
python3.9dist(certifi) = 2016.9.26
--requires --normalized-names-format pep503 --package-name python3-zope-component+testing:
--provides --majorver-provides --normalized-names-format pep503 --package-name python3-zope-component+testing:
usr/lib/python3.9/site-packages/zope.component-4.3.0-py3.9.egg-info: