diff options
author | Timothy Redaelli <tredaelli@redhat.com> | 2022-06-29 17:31:18 +0200 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-08-04 14:01:23 +0200 |
commit | 6a9ec13aa3560b339f381605afbb2fff5ba3a6e2 (patch) | |
tree | a659e6a7d026c664895d7ac15386d7eee5a3fb75 /python | |
parent | 47cfa89412fa680170fa65465d4368fe8aafa0cf (diff) | |
download | openvswitch-6a9ec13aa3560b339f381605afbb2fff5ba3a6e2.tar.gz |
python: Use setuptools instead of distutils.
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 <tredaelli@redhat.com>
Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/setup.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/python/setup.py b/python/setup.py index 1c9576aa9..062901ddd 100644 --- a/python/setup.py +++ b/python/setup.py @@ -13,9 +13,13 @@ import os 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 @@ -38,7 +42,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) @@ -54,7 +58,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): |