diff --git a/configure b/configure --- a/configure +++ b/configure @@ -2957,13 +2957,18 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5 $as_echo_n "checking for python interpreter for cross build... " >&6; } if test -z "$PYTHON_FOR_BUILD"; then - for interp in python$PACKAGE_VERSION python3 python; do - which $interp >/dev/null 2>&1 || continue - if $interp -c 'import sys;sys.exit(not sys.version_info[:2] >= (3,3))'; then - break - fi - interp= - done + if test ! -z "$HOSTPYTHON" && PYTHONPATH="$ac_abs_confdir/Lib" "$HOSTPYTHON" —S -c 'import sys;sys.exit(not sys.version_info[:2] >= (3,3))'; then + interp="$HOSTPYTHON" + else + for interp in python$PACKAGE_VERSION python3 python; do + which $interp >/dev/null 2>&1 || continue + if $interp -c 'import sys;sys.exit(not sys.version_info[:2] >= (3,3))'; then + break + fi + interp= + done + fi + if test x$interp = x; then as_fn_error $? "python$PACKAGE_VERSION interpreter not found" "$LINENO" 5 fi diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -56,13 +56,18 @@ if test "$cross_compiling" = yes; then AC_MSG_CHECKING([for python interpreter for cross build]) if test -z "$PYTHON_FOR_BUILD"; then - for interp in python$PACKAGE_VERSION python3 python; do - which $interp >/dev/null 2>&1 || continue - if $interp -c 'import sys;sys.exit(not sys.version_info@<:@:2@:>@ >= (3,3))'; then - break - fi - interp= - done + if test ! -z "$HOSTPYTHON" && PYTHONPATH="$ac_abs_confdir/Lib" "$HOSTPYTHON" -S -c 'import sys;sys.exit(not sys.version_info@<:@:2@:>@ >= (3,3))'; then + interp="$HOSTPYTHON" + else + for interp in python$PACKAGE_VERSION python3 python; do + which $interp >/dev/null 2>&1 || continue + if $interp -c 'import sys;sys.exit(not sys.version_info@<:@:2@:>@ >= (3,3))'; then + break + fi + interp= + done + fi + if test x$interp = x; then AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) fi