On Python 3.12, distutils will be removed and it's currently (3.10+) deprecated (see PEP 632).
Since the suggested and simplest replacement is setuptools, this commit replaces distutils to use setuptools instead. setuptools < 59.0 doesn't have setuptools.errors and so, in this case, distutils.errors is still used. Signed-off-by: Timothy Redaelli <[email protected]> --- v1 -> v2: - As reported by Mike Pattrick, use distutils.errors if setuptools.errors is not available (for setuptools < 59.0). --- python/setup.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/python/setup.py b/python/setup.py index cfe01763f..8ff5bb0e9 100644 --- a/python/setup.py +++ b/python/setup.py @@ -12,9 +12,13 @@ import sys -from distutils.command.build_ext import build_ext -from distutils.errors import CCompilerError, DistutilsExecError, \ - DistutilsPlatformError +from setuptools.command.build_ext import build_ext +try: + from setuptools.errors import CCompilerError, ExecError, PlatformError +except ImportError: # Needed for setuptools < 59.0 + from distutils.errors import CCompilerError + from distutils.errors import DistutilsExecError as ExecError + from distutils.errors import DistutilsPlatformError as PlatformError import setuptools @@ -37,7 +41,7 @@ except IOError: file=sys.stderr) sys.exit(-1) -ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError) +ext_errors = (CCompilerError, ExecError, PlatformError) if sys.platform == 'win32': ext_errors += (IOError, ValueError) @@ -53,7 +57,7 @@ class try_build_ext(build_ext): def run(self): try: build_ext.run(self) - except DistutilsPlatformError: + except PlatformError: raise BuildFailed() def build_extension(self, ext): -- 2.36.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
