2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

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>
This commit is contained in:
Timothy Redaelli
2022-06-29 17:31:18 +02:00
committed by Ilya Maximets
parent 47cfa89412
commit 6a9ec13aa3

View File

@@ -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):