From e9d59948b417896ba86c7e68556e09e8a4af8844 Mon Sep 17 00:00:00 2001 From: Guillaume Marcais Date: Wed, 6 Sep 2023 16:46:39 -0500 Subject: [PATCH] Configure script updates * python-devel.m4: do not use distutils package, it is deprecated. * Support to force installing to system or user site-packages with --enable-python-binding=sys|user * Updated ax_ext.m4. --- configure.ac | 2 +- m4/m4-ax_ext.m4 | 14 ++++----- m4/m4-ax_python_devel.m4 | 61 ++++++++++++++++++++++------------------ 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/configure.ac b/configure.ac index 144d40e8..86cf9985 100644 --- a/configure.ac +++ b/configure.ac @@ -116,7 +116,7 @@ AS_IF([test x$enable_all_static = xyes], maybe_swig= # --enable-python-binding AC_ARG_ENABLE([python-binding], - [AS_HELP_STRING([--enable-python-binding@<:@=PATH@:>@],[create SWIG python module and install in PATH])]) + [AS_HELP_STRING([--enable-python-binding@<:@=PATH@:>@],[create SWIG python module and install in PATH (user or system site-packages if PATH=user|sys)])]) # --enable-ruby-binding AC_ARG_ENABLE([ruby-binding], [AS_HELP_STRING([--enable-ruby-binding@<:@=PATH@:>@],[create SWIG ruby module and install in PATH])]) diff --git a/m4/m4-ax_ext.m4 b/m4/m4-ax_ext.m4 index 66de4c32..1fe6312b 100644 --- a/m4/m4-ax_ext.m4 +++ b/m4/m4-ax_ext.m4 @@ -44,7 +44,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 17 +#serial 19 AC_DEFUN([AX_EXT], [ @@ -160,22 +160,22 @@ AC_DEFUN([AX_EXT], ax_cv_have_sse_os_support_ext=no, if test "$((0x$edx_cpuid1>>25&0x01))" = 1; then AC_LANG_PUSH([C]) - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include /* No way at ring1 to ring3 in protected mode to check the CR0 and CR4 control registers directly. Execute an SSE instruction. If it raises SIGILL then OS doesn't support SSE based instructions */ void sig_handler(int signum){ exit(1); } - int main(){ + int main(void){ signal(SIGILL, sig_handler); /* SSE instruction xorps %xmm0,%xmm0 */ __asm__ __volatile__ (".byte 0x0f, 0x57, 0xc0"); return 0; - }], - ax_cv_have_sse_os_support_ext=yes, - ax_cv_have_sse_os_support_ext=no, - ax_cv_have_sse_os_support_ext=no) + }]])], + [ax_cv_have_sse_os_support_ext=yes], + [ax_cv_have_sse_os_support_ext=no], + [ax_cv_have_sse_os_support_ext=no]) AC_LANG_POP([C]) fi ]) diff --git a/m4/m4-ax_python_devel.m4 b/m4/m4-ax_python_devel.m4 index b3f1406b..2181043b 100644 --- a/m4/m4-ax_python_devel.m4 +++ b/m4/m4-ax_python_devel.m4 @@ -138,30 +138,31 @@ variable to configure. See ``configure --help'' for reference. prefix= fi + # Don't check for distutils, it is deprecated. Use module sysconfig and setuptools instead. # # Check if you have distutils, else fail # - AC_MSG_CHECKING([for the distutils Python package]) - ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` - if test -z "$ac_distutils_result"; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - AC_MSG_ERROR([cannot import Python module "distutils". -Please check your Python installation. The error was: -$ac_distutils_result]) - PYTHON_VERSION="" - fi + # AC_MSG_CHECKING([for the sysconfig Python package]) + # ac_distutils_result=`$PYTHON -c "import sysconfig" 2>&1` +# if test -z "$ac_distutils_result"; then +# AC_MSG_RESULT([yes]) +# else +# AC_MSG_RESULT([no]) +# AC_MSG_ERROR([cannot import Python module "distutils". +# Please check your Python installation. The error was: +# $ac_distutils_result]) +# PYTHON_VERSION="" +# fi # # Check for Python include path # AC_MSG_CHECKING([for Python include path]) if test -z "$PYTHON_CPPFLAGS"; then - python_path=`$PYTHON -c "import distutils.sysconfig; \ - print (distutils.sysconfig.get_python_inc ());"` - plat_python_path=`$PYTHON -c "import distutils.sysconfig; \ - print (distutils.sysconfig.get_python_inc (plat_specific=1));"` + python_path=`$PYTHON -c "import sysconfig; \ + print (sysconfig.get_path ('include'));"` + plat_python_path=`$PYTHON -c "import sysconfig; \ + print (sysconfig.get_path ('platinclude'));"` if test -n "${python_path}"; then if test "${plat_python_path}" != "${python_path}"; then python_path="-I$python_path -I$plat_python_path" @@ -185,7 +186,7 @@ $ac_distutils_result]) # join all versioning strings, on some systems # major/minor numbers could be in different list elements -from distutils.sysconfig import * +from sysconfig import * e = get_config_var('VERSION') if e is not None: print(e) @@ -208,8 +209,8 @@ EOD` ac_python_libdir=`cat< 0 and pref != '-c' else None; \ - print(distutils.sysconfig.get_python_lib(0,0,pref));" $prefix` + path = os.path.join(pref, 'lib', 'python%d.%d' % sys.version_info@<:@:2@:>@) if pref else site.getsitepackages()@<:@0@:>@; \ + print(path)" $prefix` + elif test "$PYTHON_SITE_PKG" = "user"; then + PYTHON_SITE_PKG=`$PYTHON -c "import site; print(site.getusersitepackages())"` + elif test "$PYTHON_SITE_PKG" = "sys"; then + PYTHON_SITE_PKG=`$PYTHON -c "import site; print(site.getsitepackages()@<:@0@:>@)"` fi AC_MSG_RESULT([$PYTHON_SITE_PKG]) AC_SUBST([PYTHON_SITE_PKG]) @@ -272,8 +279,8 @@ EOD` # AC_MSG_CHECKING(python extra libraries) if test -z "$PYTHON_EXTRA_LIBS"; then - PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ - conf = distutils.sysconfig.get_config_var; \ + PYTHON_EXTRA_LIBS=`$PYTHON -c "import sysconfig; \ + conf = sysconfig.get_config_var; \ print (conf('LIBS') + ' ' + conf('SYSLIBS'))"` fi AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) @@ -284,8 +291,8 @@ EOD` # AC_MSG_CHECKING(python extra linking flags) if test -z "$PYTHON_EXTRA_LDFLAGS"; then - PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \ - conf = distutils.sysconfig.get_config_var; \ + PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import sysconfig; \ + conf = sysconfig.get_config_var; \ print (conf('LINKFORSHARED'))"` fi AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])