Skip to content

Commit c440ee3

Browse files
jnsnowHyman Huang(黄勇)
authored and
Hyman Huang(黄勇)
committed
Python: add setuptools v60.0 workaround
Setuptools v60 and later include a bundled version of distutils, a deprecated standard library scheduled for removal in future versions of Python. Setuptools v60 is only possible to install for Python 3.7 and later. Python has a distutils.sysconfig.get_python_lib() function that returns '/usr/lib/pythonX.Y' on posix systems. RPM-based systems actually use '/usr/lib64/pythonX.Y' instead, so Fedora patches stdlib distutils for Python 3.7 and Python 3.8 to return the correct value. Python 3.9 and later introduce a sys.platlibdir property, which returns the correct value on RPM-based systems. The change to a distutils package not provided by Fedora on Python 3.7 and 3.8 causes a regression in distutils.sysconfig.get_python_lib() that ultimately causes false positives to be emitted by pylint, because it can no longer find the system source libraries. Many Python tools are fairly aggressive about updating setuptools packages, and so even though this package is a fair bit newer than Python 3.7/3.8, it's not entirely unreasonable for a given user to have such a modern package with a fairly old Python interpreter. Updates to Python 3.7 and Python 3.8 are being produced for Fedora which will fix the problem on up-to-date systems. Until then, we can force the loading of platform-provided distutils when running the pylint test. This is the least-invasive yet most comprehensive fix. References: pypa/setuptools#2896 pylint-dev/pylint#5704 pypa/distutils#110 Signed-off-by: John Snow <[email protected]> Message-id: [email protected] Signed-off-by: John Snow <[email protected]>
1 parent 08aa950 commit c440ee3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

python/tests/iotests-pylint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh -e
22

33
cd ../tests/qemu-iotests/
4-
python3 -m linters --pylint
4+
# See commit message for environment variable explainer.
5+
SETUPTOOLS_USE_DISTUTILS=stdlib python3 -m linters --pylint

python/tests/pylint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh -e
2-
python3 -m pylint qemu/
2+
# See commit message for environment variable explainer.
3+
SETUPTOOLS_USE_DISTUTILS=stdlib python3 -m pylint qemu/

0 commit comments

Comments
 (0)