diff --git a/macros/ax_python_devel.m4 b/macros/ax_python_devel.m4 old mode 100644 new mode 100755 index 55463ed88..1df46a9cf --- a/macros/ax_python_devel.m4 +++ b/macros/ax_python_devel.m4 @@ -67,7 +67,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 21 +#serial 23 AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) AC_DEFUN([AX_PYTHON_DEVEL],[ @@ -109,7 +109,6 @@ to something else than an empty string. fi else AC_MSG_RESULT([yes]) - sysconfig="distutils.sysconfig" fi # @@ -133,41 +132,28 @@ variable to configure. See ``configure --help'' for reference. fi fi - # - # - # Check for a version of Python >= 3.0.0 - # - AC_MSG_CHECKING([for a version of Python >= '3.0.0']) - ac_supports_python3_ver=`$PYTHON -c "import sys; \ - ver = sys.version.split ()[[0]]; \ - print (ver >= '3.0.0')"` - if test "$ac_supports_python3_ver" != "True"; then - if test -z "$PYTHON_NOVERSIONCHECK"; then - AC_MSG_RESULT([no]) - else - AC_MSG_RESULT([skip at user request]) - fi - else - sysconfig="sysconfig" - PYTHON_CPPFLAGS=`python3-config --includes` - PYTHON_EXTRA_LDFLAGS=`python3-config --ldflags` - AC_MSG_RESULT([yes]) - fi - - # # Check if you have distutils, else fail # - AC_MSG_CHECKING([for the distutils Python package]) - ac_distutils_result=`$PYTHON -c "import $sysconfig" 2>&1` + AC_MSG_CHECKING([for the sysconfig Python package]) + ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1` if test $? -eq 0; then AC_MSG_RESULT([yes]) + IMPORT_SYSCONFIG="import sysconfig" else AC_MSG_RESULT([no]) - AC_MSG_ERROR([cannot import Python module "distutils". + + AC_MSG_CHECKING([for the distutils Python package]) + ac_sysconfig_result=`$PYTHON -c "from distutils import sysconfig" 2>&1` + if test $? -eq 0; then + AC_MSG_RESULT([yes]) + IMPORT_SYSCONFIG="from distutils import sysconfig" + else + AC_MSG_ERROR([cannot import Python module "distutils". Please check your Python installation. The error was: -$ac_distutils_result]) - PYTHON_VERSION="" +$ac_sysconfig_result]) + PYTHON_VERSION="" + fi fi # @@ -175,10 +161,19 @@ $ac_distutils_result]) # AC_MSG_CHECKING([for Python include path]) if test -z "$PYTHON_CPPFLAGS"; then - python_path=`$PYTHON -c "import $sysconfig; \ - print ($sysconfig.get_python_inc ());"` - plat_python_path=`$PYTHON -c "import $sysconfig; \ - print ($sysconfig.get_python_inc (plat_specific=1));"` + if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then + # sysconfig module has different functions + python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ + print (sysconfig.get_path ('include'));"` + plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ + print (sysconfig.get_path ('platinclude'));"` + else + # old distutils way + python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ + print (sysconfig.get_python_inc ());"` + plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ + print (sysconfig.get_python_inc (plat_specific=1));"` + fi if test -n "${python_path}"; then if test "${plat_python_path}" != "${python_path}"; then python_path="-I$python_path -I$plat_python_path" @@ -202,7 +197,7 @@ $ac_distutils_result]) # join all versioning strings, on some systems # major/minor numbers could be in different list elements -from $sysconfig import * +from sysconfig import * e = get_config_var('VERSION') if e is not None: print(e) @@ -225,8 +220,8 @@ EOD` ac_python_libdir=`cat<