fix detection of python version 3

configure errors:
../mpich/configure: line 21398: python: command not found
../mpich/configure: line 21398: test: 3: unary operator expected
Esse commit está contido em:
wkliao
2024-04-06 13:55:04 -05:00
commit de Hui Zhou
commit 6a9299620f
+23 -7
Ver Arquivo
@@ -3,17 +3,33 @@ dnl
AC_DEFUN([PAC_CHECK_PYTHON],[
AC_ARG_VAR([PYTHON], [set to Python 3])
if test -z "$PYTHON" ; then
AC_MSG_CHECKING([Python 3])
PYTHON=
python_one_liner="import sys; print(sys.version_info[[0]])"
if test 3 = `python -c "$python_one_liner"`; then
PYTHON=python
elif test 3 = `python3 -c "$python_one_liner"`; then
PYTHON=python3
dnl check command 'python'
PYTHON_PATH=
AC_PATH_PROG(PYTHON_PATH, python)
if test "x$PYTHON_PATH" != x ; then
py_version=`$PYTHON_PATH -c "$python_one_liner"`
if test "x$py_version" = x3 ; then
PYTHON=$PYTHON_PATH
fi
fi
dnl PYTHON is still not set, check command 'python3'
if test "x$PYTHON" = x ; then
PYTHON3_PATH=
AC_PATH_PROG(PYTHON3_PATH, python3)
if test "x$PYTHON3_PATH" != x ; then
py3_version=`$PYTHON3_PATH -c "$python_one_liner"`
if test "x$py3_version" = x3 ; then
PYTHON=$PYTHON3_PATH
fi
fi
fi
AC_MSG_RESULT($PYTHON)
if test -z "$PYTHON" ; then
AC_MSG_WARN([Python 3 not found! Bindings need to be generated before configure.])
AC_MSG_WARN([Python version 3 not found! Bindings need to be generated before configure.])
else
AC_MSG_NOTICE([Python version 3 is $PYTHON])
fi
fi
])