setup: Plan for newer setuptools providing distutils back compat

setuptools still doesn't natively provide some infrastructure we
need, but newer versions will keep 'import distutils' working until
those issues are addressed. I think we need to reorder imports to take
advantage of it though. It silences some deprecation warnings at
least

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson
2022-01-27 10:19:43 -05:00
parent 16fecb482a
commit 7ee01c7eeb
+11 -6
View File
@@ -17,16 +17,21 @@ import shutil
import sysconfig
import subprocess
# distutils will be deprecated in python 3.12 in favor of setuptools,
# but as of this writing there's standard no setuptools way to extend the
# 'build' or 'build_scripts' commands which are the only standard
# commands we trigger.
import distutils.command.build
import setuptools
import setuptools.command.install
import setuptools.command.install_egg_info
# distutils will be deprecated in python 3.12 in favor of setuptools,
# but as of this writing there's standard no setuptools way to extend the
# 'build' commands which are the only standard commands we trigger.
# https://github.com/pypa/setuptools/issues/2591
#
# Newer setuptools will transparently support 'import distutils' though.
# That can be overridden with SETUPTOOLS_USE_DISTUTILS env variable
import distutils.command.build # pylint: disable=wrong-import-order
SYSPREFIX = sysconfig.get_config_var("prefix")