From 6ec97181a525a3cd64cedbcd0df905ed9e84ba03 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 27 Feb 2023 13:40:08 -0500 Subject: [PATCH] python: replace distutils with setuptools MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.lttng.org/c/babeltrace/+/8846 Reviewed-by: Jérémie Galarneau Reviewed-by: Simon Marchi Tested-by: jenkins --- configure.ac | 10 ++++++++++ src/bindings/python/bt2/setup.py.in | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 5dcb8bfe..b78e457e 100644 --- a/configure.ac +++ b/configure.ac @@ -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], diff --git a/src/bindings/python/bt2/setup.py.in b/src/bindings/python/bt2/setup.py.in index d6f7c902..fff97087 100644 --- a/src/bindings/python/bt2/setup.py.in +++ b/src/bindings/python/bt2/setup.py.in @@ -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------------------------------------ -- 2.34.1