On Wed, May 11, 2022 at 2:14 PM Timothy Redaelli <[email protected]> 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.
>
> Signed-off-by: Timothy Redaelli <[email protected]>
> ---
>  python/setup.py | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/python/setup.py b/python/setup.py
> index cfe01763f..7c7418bd9 100644
> --- a/python/setup.py
> +++ b/python/setup.py
> @@ -12,9 +12,8 @@
>
>  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
> +from setuptools.errors import CCompilerError, ExecError, PlatformError


I tried applying this patch on RHEL 8.5 with Python 3.6.8 and
setuptools 39.2.0, and got the following error:

Processing /home/test/ovs_mod/python
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-v08_3iao-build/setup.py", line 16, in <module>
        from setuptools.errors import CCompilerError, ExecError, PlatformError
    ModuleNotFoundError: No module named 'setuptools.errors'

You could use this sort of motif to improve backwards compatibility:

try:
    from A import B
except ImportError:
    from C import D as B


Cheers,
M

>
>  import setuptools
>
> @@ -37,7 +36,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 +52,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
>

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to