Message ID | a941717f8c168b95b5d142bbf18bf5ea9efcb3ba.1656516353.git.tredaelli@redhat.com |
---|---|
State | Accepted |
Commit | 6a9ec13aa3560b339f381605afbb2fff5ba3a6e2 |
Headers | show |
Series | [ovs-dev,v2] python: use setuptools instead of distutils | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | fail | github build: failed |
ovsrobot/intel-ovs-compilation | success | test: success |
On Wed, Jun 29, 2022 at 11:31 AM Timothy Redaelli <tredaelli@redhat.com> wrote: > > 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> LGTM! Acked-by: Mike Pattrick <mkp@redhat.com>
On 7/11/22 14:24, Mike Pattrick wrote: > On Wed, Jun 29, 2022 at 11:31 AM Timothy Redaelli <tredaelli@redhat.com> wrote: >> >> 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> > > LGTM! > > Acked-by: Mike Pattrick <mkp@redhat.com> Thanks! Applied and backported down to 2.17 to avoid issues on a future LTS branch. Best regards, Ilya Maximets.
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):
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> --- 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(-)