#538 Fix tests on Python 3.12 by fixing pkg_resources dependency
Merged by onosek. Opened by dherrera.
dherrera/fedpkg python312-tests  into  master

Download 538.patch

I've been studying fedpkg code and noticed that the tests were failing to run on python 3.12. The main cause of this is that the pkg_resources library can't be found during the testing process when testing on python 3.12.

Digging around, I found out that the thing that causes this problem is that python 3.12 stopped preinstalling the setuptools library in virtual environments created with venv [0]. This can be easily fixed by adding the setuptools requirement to the requirements.txt file, but I also noticed that the pkg_resources API being used in fedpkg was a deprecated API [1], so I changed the code so that fedpkg prioritizes using the importlib library when available instead as recommended by upstream[1].

[0] https://docs.python.org/3/whatsnew/3.12.html
[1] https://setuptools.pypa.io/en/latest/pkg_resources.html

@onosek would you mind taking a look at this PR and providing feedback?

rebased onto 98afc53431d01e1aadbcf33c48da673246029410

Thanks, @dherrera for the change, including unittests fixes. I did some basic testing.

It should not require any new package dependencies, right?
In the specfile, there are already:
python3-devel (it transitively requires python3-packaging)
python3-distro

Pull-Request has been merged by onosek

Metadata