This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 1/3] configure: Fix handling of python versions 2 and 3


When python version 2 is not found, AM_PROG_PYTHON sets the output
variable PYTHON to ":" (which is intentional; see "man 1P colon").
Fix incorrect tests that compared PYTHON to an empty string.

Use the same behavior for python version 3: when it is not found,
set the output variable PYTHON3 to ":" and test that accordingly.

Pass the variables "python3" and "py3execdir" to the subconfigure
unconditionally, just like the variables "python" and "pyexecdir".

When a program named "python" exists, fix a conditional that tests
if it is python version 3.

Do not guess the name of the python-config script. Simply append
"-config" to the program name for the python interpreter.
---
 configure    | 48 +++++++++++++++++++++---------------------------
 configure.ac | 34 ++++++++++++++++------------------
 2 files changed, 37 insertions(+), 45 deletions(-)

diff --git a/configure b/configure
index 48d8906..a0a784c 100755
--- a/configure
+++ b/configure
@@ -1638,7 +1638,7 @@ Optional Packages:
   --with-dracutbindir=DIR Use the dracut binary located in DIR
   --without-avahi         Do not use Avahi even if present
   --with-rpm              query rpm database for missing debuginfos
-  --with-python3          prefer /usr/bin/python3
+  --with-python3          prefer python version 3
   --with-elfutils=DIRECTORY
                           find elfutils source code in DIRECTORY
   --with-dyninst=DIRECTORY
@@ -9164,7 +9164,7 @@ cat >>confdefs.h <<_ACEOF
 #define PYTHON_BASENAME "${python_basename}"
 _ACEOF
 
-if test -n "$PYTHON"; then
+if test "x$PYTHON" != "x:"; then
 
 $as_echo "#define PYTHON_EXISTS /**/" >>confdefs.h
 
@@ -9176,7 +9176,7 @@ fi
 as_fn_append ac_configure_args " python='$PYTHON' pyexecdir='$pyexecdir'"
 
 # Now let's try to find python version 3.
-if test "x$PYTHON_UNKNOWN" != "xno" -a "x$python_unknown_version" = "x3"; then
+if test "x$PYTHON_UNKNOWN" != "xno" -a "x$ac_cv_python_unknown_version" = "x3"; then
    # Extract the first word of "python", so it can be a program name with args.
 set dummy python; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -9218,7 +9218,7 @@ fi
 
 
 else
-   for ac_prog in python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0
+   for ac_prog in python3 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -9262,6 +9262,7 @@ fi
 
   test -n "$PYTHON3" && break
 done
+test -n "$PYTHON3" || PYTHON3=":"
 
 fi
 python3_basename=$(basename "$PYTHON3")
@@ -9273,7 +9274,7 @@ _ACEOF
 
 # If we found python version 3, set up the other variables for python
 # version 3 that AM_PATH_PYTHON sets up for python version 2.
-if test -n "$PYTHON3"; then
+if test "x$PYTHON3" != "x:"; then
 
 $as_echo "#define PYTHON3_EXISTS /**/" >>confdefs.h
 
@@ -9327,12 +9328,12 @@ fi
 $as_echo "$ac_cv_py3execdir" >&6; }
    py3execdir=$ac_cv_py3execdir
 
-
-   # Make sure the python3 and py3execdir variables get sent down to
-   # the subconfigure in the testsuite directory.
-   as_fn_append ac_configure_args " python3='$PYTHON3' py3execdir='$ac_cv_py3execdir'"
 fi
 
+# Make sure the python3 and py3execdir variables get sent down to
+# the subconfigure in the testsuite directory.
+as_fn_append ac_configure_args " python3='$PYTHON3' py3execdir='$ac_cv_py3execdir'"
+
 if test "${enable_prologues+set}" != set; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking to see if prologue searching should be the default" >&5
 $as_echo_n "checking to see if prologue searching should be the default... " >&6; }
@@ -11395,7 +11396,7 @@ if test "${with_python3+set}" = set; then :
 fi
 
 if test "x$with_python3" = "xyes"; then :
-  if test -z "$PYTHON3"; then :
+  if test "x$PYTHON3" = "x:"; then :
   as_fn_error $? "python version 3 is required" "$LINENO" 5
 else
   preferred_python=$PYTHON3
@@ -12135,10 +12136,9 @@ fi
 
 have_python2_support=no
 if test "x$with_python2_probes" != "xno"; then :
-     for ac_prog in python2-config python-config
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
+     if test "x$PYTHON" != "x:"; then :
+  # Extract the first word of "${python_basename}-config", so it can be a program name with args.
+set dummy ${python_basename}-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if ${ac_cv_path_PYTHON_CONFIG+:} false; then :
@@ -12177,11 +12177,8 @@ $as_echo "no" >&6; }
 fi
 
 
-  test -n "$PYTHON_CONFIG" && break
-done
-test -n "$PYTHON_CONFIG" || PYTHON_CONFIG="no"
-
-   if test "x$PYTHON_CONFIG" != "xno"; then :
+fi
+   if test "x$PYTHON_CONFIG" != "x"; then :
   	  	  PYTHON_CPPFLAGS=`$PYTHON_CONFIG --includes 2> /dev/null`
 	  PYTHON_CPPFLAGS=$PYTHON_CPPFLAGS
 
@@ -12230,12 +12227,9 @@ fi
 
 have_python3_support=no
 if test "x$with_python3_probes" != "xno"; then :
-     pathless_python3=$(basename "$PYTHON3")
-   if test "x${pathless_python3}" == "x"; then
-	pathless_python3="python3"
-   fi
-   # Extract the first word of "${pathless_python3}-config", so it can be a program name with args.
-set dummy ${pathless_python3}-config; ac_word=$2
+     if test "x$PYTHON3" != "x:" ; then :
+  # Extract the first word of "${python3_basename}-config", so it can be a program name with args.
+set dummy ${python3_basename}-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if ${ac_cv_path_PYTHON3_CONFIG+:} false; then :
@@ -12261,7 +12255,6 @@ done
   done
 IFS=$as_save_IFS
 
-  test -z "$ac_cv_path_PYTHON3_CONFIG" && ac_cv_path_PYTHON3_CONFIG="no"
   ;;
 esac
 fi
@@ -12275,7 +12268,8 @@ $as_echo "no" >&6; }
 fi
 
 
-   if test "x$PYTHON3_CONFIG" != "xno"; then :
+fi
+   if test "x$PYTHON3_CONFIG" != "x"; then :
   	  	  PYTHON3_CPPFLAGS=`$PYTHON3_CONFIG --includes 2> /dev/null`
 	  PYTHON3_CPPFLAGS=$PYTHON3_CPPFLAGS
 
diff --git a/configure.ac b/configure.ac
index a545dc2..378b1dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,7 +80,7 @@ AM_PATH_PYTHON([2.6], [], [:])
 python_basename=$(basename "$PYTHON")
 AC_DEFINE_UNQUOTED([PYTHON_BASENAME], "${python_basename}",
 		   [Base name of the python2 interpreter binary.])
-if test -n "$PYTHON"; then
+if test "x$PYTHON" != "x:"; then
 AC_DEFINE([PYTHON_EXISTS], [],
 	  [The python2 interpreter binary exists.])
 fi
@@ -91,11 +91,11 @@ fi
 AS_VAR_APPEND([ac_configure_args], [" python='$PYTHON' pyexecdir='$pyexecdir'"])
 
 # Now let's try to find python version 3.
-if test "x$PYTHON_UNKNOWN" != "xno" -a "x$python_unknown_version" = "x3"; then
+if test "x$PYTHON_UNKNOWN" != "xno" -a "x$ac_cv_python_unknown_version" = "x3"; then
    AC_PATH_PROG([PYTHON3], [python])
 else
    AC_PATH_PROGS([PYTHON3],
-		 [python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0])
+		 [python3 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0], [:])
 fi
 python3_basename=$(basename "$PYTHON3")
 AC_DEFINE_UNQUOTED([PYTHON3_BASENAME], "${python3_basename}",
@@ -103,7 +103,7 @@ AC_DEFINE_UNQUOTED([PYTHON3_BASENAME], "${python3_basename}",
 
 # If we found python version 3, set up the other variables for python
 # version 3 that AM_PATH_PYTHON sets up for python version 2.
-if test -n "$PYTHON3"; then
+if test "x$PYTHON3" != "x:"; then
    AC_DEFINE([PYTHON3_EXISTS], [],
 	     [The python3 interpreter binary exists.])
    AC_CACHE_CHECK([for python3 version], [ac_cv_python3_version],
@@ -123,12 +123,12 @@ if test -n "$PYTHON3"; then
    		  [ac_cv_py3execdir],
 		  [ac_cv_py3execdir=`$PYTHON3 -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(1,0,prefix='$PYTHON3_EXEC_PREFIX'))"`])
    AC_SUBST([py3execdir], [$ac_cv_py3execdir])
-
-   # Make sure the python3 and py3execdir variables get sent down to
-   # the subconfigure in the testsuite directory.
-   AS_VAR_APPEND([ac_configure_args], [" python3='$PYTHON3' py3execdir='$ac_cv_py3execdir'"])
 fi
 
+# Make sure the python3 and py3execdir variables get sent down to
+# the subconfigure in the testsuite directory.
+AS_VAR_APPEND([ac_configure_args], [" python3='$PYTHON3' py3execdir='$ac_cv_py3execdir'"])
+
 dnl Handle the prologues option.
 dnl
 dnl If the user didn't specify --enable-prologues/--disable-prologues
@@ -561,9 +561,9 @@ LIBS=$LIBS_no_readline
 
 dnl Allow user to choose python3 for /usr/bin/dtrace
 AC_ARG_WITH([python3],
-  AS_HELP_STRING([--with-python3],[prefer /usr/bin/python3]))
+  AS_HELP_STRING([--with-python3],[prefer python version 3]))
 AS_IF([test "x$with_python3" = "xyes"],
-      [AS_IF([test -z "$PYTHON3"],
+      [AS_IF([test "x$PYTHON3" = "x:"],
              [AC_MSG_ERROR([python version 3 is required])],
 	     [AC_SUBST(preferred_python,[$PYTHON3])])],
       [AS_IF([test "x$PYTHON" = "x:"],
@@ -735,8 +735,9 @@ AC_ARG_WITH([python2-probes],
 have_python2_support=no
 AS_IF([test "x$with_python2_probes" != "xno"],
   [dnl First, check to make sure we have the 'python-config' script.
-   AC_PATH_PROGS([PYTHON_CONFIG], [python2-config python-config], [no])
-   AS_IF([test "x$PYTHON_CONFIG" != "xno"],
+   AS_IF([test "x$PYTHON" != "x:"],
+	 [AC_PATH_PROG([PYTHON_CONFIG], [${python_basename}-config])])
+   AS_IF([test "x$PYTHON_CONFIG" != "x"],
 	 [dnl Use the 'python-config' script to find the python
 	  dnl include directories.
 	  PYTHON_CPPFLAGS=`$PYTHON_CONFIG --includes 2> /dev/null`
@@ -765,12 +766,9 @@ AC_ARG_WITH([python3-probes],
 have_python3_support=no
 AS_IF([test "x$with_python3_probes" != "xno"],
   [dnl First, check to make sure we have the 'python3-config' script.
-   pathless_python3=$(basename "$PYTHON3")
-   if test "x${pathless_python3}" == "x"; then
-	pathless_python3="python3"   
-   fi
-   AC_PATH_PROG([PYTHON3_CONFIG], [${pathless_python3}-config], [no])
-   AS_IF([test "x$PYTHON3_CONFIG" != "xno"],
+   AS_IF([test "x$PYTHON3" != "x:" ],
+	 [AC_PATH_PROG([PYTHON3_CONFIG], [${python3_basename}-config])])
+   AS_IF([test "x$PYTHON3_CONFIG" != "x"],
 	 [dnl Use the 'python3-config' script to find the python
 	  dnl include directories.
 	  PYTHON3_CPPFLAGS=`$PYTHON3_CONFIG --includes 2> /dev/null`
-- 
1.8.3.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]