Commit 84eda2c7a7731158d47f132aaba4175450075aab
1 parent
43562468
Detect Python attributes using sysconfig of distutils.sysconfig module, depending on availability
Showing
1 changed file
with
25 additions
and
6 deletions
configure.ac
... | ... | @@ -919,6 +919,15 @@ else |
919 | 919 | AC_SUBST(PYTHON_OPEN) |
920 | 920 | AC_SUBST(PYTHON_CLOSE) |
921 | 921 | |
922 | + # Do we have sysconfig? | |
923 | + AC_MSG_CHECKING([for the sysconfig Python package]) | |
924 | + ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1` | |
925 | + if test -z "$ac_sysconfig_result"; then | |
926 | + AC_MSG_RESULT([yes]) | |
927 | + else | |
928 | + AC_MSG_RESULT([no]) | |
929 | + fi | |
930 | + | |
922 | 931 | # Do we have distutils? |
923 | 932 | AC_MSG_CHECKING([for the distutils Python package]) |
924 | 933 | ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` |
... | ... | @@ -938,12 +947,17 @@ else |
938 | 947 | AC_MSG_RESULT([no]) |
939 | 948 | fi |
940 | 949 | |
941 | - # If we have distutils then get python path from distutils ... | |
942 | - if test -z "$ac_distutils_result"; then | |
950 | + # If we have sysconfig or distutils then get python path | |
951 | + if test -z "$ac_sysconfig_result" || test -z "$ac_distutils_result"; then | |
943 | 952 | |
944 | 953 | # Get Python path |
945 | - python_path=`$PYTHON -c "import distutils.sysconfig; \ | |
946 | - print(distutils.sysconfig.get_python_inc());"` | |
954 | + if test -z "$ac_sysconfig_result"; then | |
955 | + python_path=`$PYTHON -c "import sysconfig; \ | |
956 | + print(sysconfig.get_paths()[['include']]);"` | |
957 | + else | |
958 | + python_path=`$PYTHON -c "import distutils.sysconfig; \ | |
959 | + print(distutils.sysconfig.get_python_inc());"` | |
960 | + fi | |
947 | 961 | if test -n "${python_path}"; then |
948 | 962 | SAVED_CPPFLAGS="$CPPFLAGS" |
949 | 963 | CPPFLAGS="$CPPFLAGS -I$python_path" |
... | ... | @@ -960,8 +974,13 @@ else |
960 | 974 | # changed from Mac OS X 10.9 on. |
961 | 975 | if [test "x$osx_mavericks" = "xyes"]; then |
962 | 976 | AC_MSG_CHECKING([Python MACOSX_DEPLOYMENT_TARGET]) |
963 | - python_target=`$PYTHON -c "from distutils import sysconfig; \ | |
964 | - print(sysconfig.get_config_vars()[['MACOSX_DEPLOYMENT_TARGET']]);" 2> /dev/null` | |
977 | + if test -z "$ac_sysconfig_result"; then | |
978 | + python_target=`$PYTHON -c "import sysconfig; \ | |
979 | + print(sysconfig.get_config_vars()[['MACOSX_DEPLOYMENT_TARGET']]);" 2> /dev/null` | |
980 | + else | |
981 | + python_target=`$PYTHON -c "from distutils import sysconfig; \ | |
982 | + print(sysconfig.get_config_vars()[['MACOSX_DEPLOYMENT_TARGET']]);" 2> /dev/null` | |
983 | + fi | |
965 | 984 | python_compact_target=`echo $python_target | sed 's/\(10\.[[0-9]]*\).*/\1/' | sed -e 's/\.//g'` |
966 | 985 | case $python_compact_target in |
967 | 986 | (*[!0-9]*|'') | ... | ... |