python: replace distutils with setuptools
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 27 Feb 2023 18:40:08 +0000 (13:40 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 7 Mar 2023 21:58:51 +0000 (16:58 -0500)
Since 'distutils' will be removed in Python 3.12, use setuptools instead
to build the bindings. Thanks to the python devs that removed the only
facility to build native extensions from the core distribution.

See https://peps.python.org/pep-0632/

Change-Id: Ib515931d2352416bcc92e18be6b5a3981fb3f067
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8846
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
configure.ac
src/bindings/python/bt2/setup.py.in

index 5dcb8bfe79888900c336edf55a148ddc43f4e209..b78e457ebbc316d55d3bb8fef9446ee9c9de3de2 100644 (file)
@@ -538,6 +538,16 @@ AS_IF([AE_IS_FEATURE_ENABLED([python-bindings]) || AE_IS_FEATURE_ENABLED([python
   AS_IF([test "x$have_python_dev" = xno], [
     AC_MSG_ERROR([Cannot find a suitable python-config. You can override the python-config path with the PYTHON_CONFIG environment variable.])
   ])
+
+  AX_COMPARE_VERSION(["$PYTHON_VERSION"], [ge], ["3.12"], [
+    AC_MSG_CHECKING([for python setuptools])
+    AS_IF(["$PYTHON" -c "import setuptools" 2>/dev/null], [
+      AC_MSG_RESULT([yes])
+    ], [
+      AC_MSG_RESULT([no])
+      AC_MSG_ERROR([Python >= 3.12 removed 'distutils', the 'setuptools' module needs to be installed for the selected interpreter.])
+    ])
+  ])
 ])
 
 AE_IF_FEATURE_ENABLED([python-bindings-doc],
index d6f7c90281e26e2f106f3376f4b70acae6cf4f18..fff970870f83f705a4a4ae54e6aee959d060b612 100644 (file)
@@ -7,7 +7,10 @@ import sys
 import os
 import sysconfig
 
-from distutils.core import setup, Extension
+if sys.version_info < (3, 12):
+    from distutils.core import setup, Extension
+else:
+    from setuptools import setup, Extension
 
 PY_PATH_WARN_MSG = """
 -------------------------------------WARNING------------------------------------
This page took 0.025499 seconds and 4 git commands to generate.