From fa94ef0412c4f24d49aa6dfbd15e3634d52d1ff5 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 22 Feb 2018 15:02:56 +0100 Subject: [PATCH] autoconf prefers Python 3 over 2 The configure script now looks for Python 3.6 or newer, then falls back to Python 2. All Makefile default to Python 3 if Python 3 is available. See: pagure.io/freeipa/issue/7131 Signed-off-by: Christian Heimes Reviewed-By: Alexander Bokovoy --- configure.ac | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 4b661ecef..50371434a 100644 --- a/configure.ac +++ b/configure.ac @@ -100,27 +100,28 @@ PKG_CHECK_MODULES([CRYPTO], [libcrypto]) dnl --------------------------------------------------------------------------- dnl - Check for Python -dnl --------------------------------------------------------------------------- - -AC_MSG_NOTICE([Checking for Python]) -have_python=no -AM_PATH_PYTHON(2.7) - -if test "x$PYTHON" = "x" ; then - AC_MSG_ERROR([Python not found]) -fi - -dnl --------------------------------------------------------------------------- dnl - Check for Python 2/3 for devcheck dnl --------------------------------------------------------------------------- +AC_MSG_NOTICE([Checking for Python 3]) +AC_PATH_PROG(PYTHON3, python3) +AC_SUBST([PYTHON3]) +AM_CONDITIONAL([WITH_PYTHON3], [test "x${PYTHON3}" != "x"]) + +AC_MSG_NOTICE([Checking for Python 2]) AC_PATH_PROG(PYTHON2, python2) AC_SUBST([PYTHON2]) AM_CONDITIONAL([WITH_PYTHON2], [test "x${PYTHON2}" != "x"]) -AC_PATH_PROG(PYTHON3, python3) -AC_SUBST([PYTHON3]) -AM_CONDITIONAL([WITH_PYTHON3], [test "x${PYTHON3}" != "x"]) +if test \( "x${PYTHON3}" = "x" -o "x${PYTHON}" != "x" \); then + dnl Python 3 is not available *or* user has set PYTHON variable. + dnl Accept Python >= 2.7 as default Python. We also accept any Python 3 + dnl version from PYTHON environment variable. + AM_PATH_PYTHON(2.7) +elif test "x${PYTHON3}" != "x"; then + dnl Found Python 3, but no user override. Use Python >= 3.6 as default. + AM_PATH_PYTHON(3.6) +fi dnl --------------------------------------------------------------------------- dnl - Check for cmocka unit test framework http://cmocka.cryptomilk.org/ @@ -590,7 +591,9 @@ echo " source code location: ${srcdir} compiler: ${CC} cflags: ${CFLAGS} - Python: ${PYTHON} + Default Python: ${PYTHON} (${PYTHON_VERSION}) + Python 2: ${PYTHON2} + Python 3: ${PYTHON3} pylint: ${PYLINT} jslint: ${JSLINT} LDAP libs: ${LDAP_LIBS}