[PULL 12/14] python/setup.py: Drop version checking via pkg_resources

Thomas Huth posted 14 patches 1 month, 4 weeks ago
Maintainers: Aurelien Jarno <aurelien@aurel32.net>, Peter Maydell <peter.maydell@linaro.org>, "Alex Bennée" <alex.bennee@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Matthew Rosato <mjrosato@linux.ibm.com>, Farhan Ali <alifm@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Ilya Leoshkevich <iii@linux.ibm.com>, David Hildenbrand <david@kernel.org>, Cornelia Huck <cohuck@redhat.com>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>
There is a newer version of this series
[PULL 12/14] python/setup.py: Drop version checking via pkg_resources
Posted by Thomas Huth 1 month, 4 weeks ago
From: Thomas Huth <thuth@redhat.com>

pkg_resources has been dropped from setuptools v82.0 and newer,
so our setup.py script is currently failing there, breaking our CI.
To fix it, switch to a direct version check instead.
While we're at it, also bump the minimum version of setuptools
to v44 now since that is the minimum that might still be in use
on the distros we care about according to:
 https://repology.org/project/python%3Asetuptools/versions

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20260211161154.740256-1-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 python/setup.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/python/setup.py b/python/setup.py
index c5bc45919a4..ae242ac95ac 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -7,7 +7,6 @@
 import setuptools
 from setuptools.command import bdist_egg
 import sys
-import pkg_resources
 
 
 class bdist_egg_guard(bdist_egg.bdist_egg):
@@ -30,8 +29,8 @@ def main():
     QEMU tooling installer
     """
 
-    # https://medium.com/@daveshawley/safely-using-setup-cfg-for-metadata-1babbe54c108
-    pkg_resources.require('setuptools>=39.2')
+    if int(setuptools.__version__.split('.')[0]) < 44:
+        raise ModuleNotFoundError('version of setuptools is too old')
 
     setuptools.setup(cmdclass={'bdist_egg': bdist_egg_guard})
 
-- 
2.53.0