From f83d02f3140ae50a266bec2193587bdfe05fbcf0 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 27 Apr 2022 14:54:06 +0200 Subject: [PATCH] Revert "Use the AM_PATH_PYTHON macro instead of custom macros" This reverts commit 23d91efac34fed8c338a388449e763e58527b3d3. --- bindings/python/Makefile.am | 1 + configure.ac | 39 ++++++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am index 8e447ba6..e44ad6d5 100644 --- a/bindings/python/Makefile.am +++ b/bindings/python/Makefile.am @@ -9,6 +9,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ $(SASL_CFLAGS) +pythondir= $(PY_SITE_PACKAGES) nodist_python_DATA = lasso.py python_LTLIBRARIES = _lasso.la diff --git a/configure.ac b/configure.ac index 0f576449..adf0be50 100644 --- a/configure.ac +++ b/configure.ac @@ -324,17 +324,42 @@ fi dnl need to change quotes to allow square brackets changequote(<<, >>)dnl -PYTHON_VERSION=`$PYTHON --version | sed "s/Python //"` +PYTHON_VERSION=`$PYTHON -c 'from distutils import sysconfig ; print(sysconfig.get_config_var("VERSION"))'` changequote([, ])dnl -AM_PATH_PYTHON([$PYTHON_VERSION],[languages_available="$languages_available python($PYTHON_VERSION)" -PY_CFLAGS="`${PYTHON}-config --cflags`" -AC_SUBST(PY_CFLAGS)],[ -enable_python=no -]) - test "x$PYTHON" != "x" || AC_MSG_ERROR(Python must be installed to compile lasso) +AC_MSG_CHECKING(for Python development files) +dnl Check if we were be able to extract a good version number. +if test "X$PYTHON_VERSION" != "X"; then + changequote(<<, >>)dnl + PYTHON_INC=`$PYTHON -c 'from distutils import sysconfig ; print(sysconfig.get_python_inc())'` + PYTHON_LIB=`$PYTHON -c 'from distutils import sysconfig ; print(sysconfig.get_python_lib(1))'` + changequote([, ])dnl + PYTHON_H=$PYTHON_INC/Python.h + if test -f $PYTHON_H; then + PY_CFLAGS="-I$PYTHON_INC" + PY_MAKEFILE=`$PYTHON -c 'from distutils import sysconfig ; print(sysconfig.get_makefile_filename())'` + PY_OTHER_LIBS=`$SED -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE` + PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASEMODLIBS $PY_OTHER_LIBS" + dnl this extracts the $libdir out of python lib directory, + dnl replacing it by our own. + PY_SUFFIX_LIB=`echo $PYTHON_LIB | $SED -e 's/.*python/python/'` + PY_SITE_PACKAGES="\${libdir}/$PY_SUFFIX_LIB" + AC_SUBST(PYTHON) + AC_SUBST(PY_LIB_LOC) + AC_SUBST(PY_CFLAGS) + AC_SUBST(PY_EXTRA_LIBS) + AC_SUBST(PY_DYNLOAD) + AC_SUBST(PY_LIB_A) + AC_SUBST(PY_SITE_PACKAGES) + languages_available="$languages_available python($PYTHON_VERSION)" + else + enable_python=no + fi +else + enable_python=no +fi AM_CONDITIONAL([PYTHON_ENABLED],[test "x$enable_python" = "xyes"]) AC_MSG_RESULT($enable_python) AC_SUBST(PYTHON_VERSION)