Skip to contentSkip to conversation

tools/configure: Allow specifying python to be found from path

PATCH In review Ian Jackson 2 participants 2 messages Sep 18, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/configure: Allow specifying python to be found from path

./configure takes a PYTHON=... argument. You can use this to specify the python interpreter. However, for no good reason, it expects an absolute path.

Fix this. The new logic is:
* if not set, default to `python'
* if not absolute, look it up with type -p
* split into directory and executable name

The results in config/Tools.mk (which contains @PYTHON@ and @PYTHONPATH@) are identical for both
./configure
./configure PYTHON=/usr/bin/python
so I assert this has no functional change except that now you can say
./configure PYTHON=python

In particular you can now say
./configure PYTHON=python2
./configure PYTHON=python3

The latter is useful if you want python3 (which should probably be the default, but does not work right now). The former is useful if you want python2 but your distro has foolishly made "python" refer to python3.

CC Doug Goldstein <[email protected]>
CC Wei Liu <[email protected]>
CC George Dunlap <[email protected]>
---
 tools/configure    | 13 +++++++------
 tools/configure.ac | 10 +++++-----
 2 files changed, 12 insertions(+), 11 deletions(-)
tools/configure +7 -6
index 1baacea9ac..f2c66dfce9 100755
@@ -6925,16 +6925,17 @@ then
     as_fn_error $? "Unable to find bash, please install bash" "$LINENO" 5
 fi;;
 esac
+if test -z "$PYTHON"; then :
+  PYTHON="python"
+fi
 if echo "$PYTHON" | grep -q "^/"; then :
 
-    PYTHONPATH=$PYTHON
-    PYTHON=`basename $PYTHONPATH`
-
-elif test -z "$PYTHON"; then :
-  PYTHON="python"
 else
-  as_fn_error $? "PYTHON specified, but is not an absolute path" "$LINENO" 5
+  PYTHON=`type -p "$PYTHON"`
 fi
+PYTHONPATH=$PYTHON
+PYTHON=`basename $PYTHONPATH`
+
 # 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
tools/configure.ac +5 -5
index 3fe04907a2..674bd5809d 100644
@@ -337,11 +337,11 @@ case "$host_os" in
   freebsd*) ;;
   *) AX_PATH_PROG_OR_FAIL([BASH], [bash]);;
 esac
-AS_IF([echo "$PYTHON" | grep -q "^/"], [
-    PYTHONPATH=$PYTHON
-    PYTHON=`basename $PYTHONPATH`
-],[test -z "$PYTHON"], [PYTHON="python"],
-[AC_MSG_ERROR([PYTHON specified, but is not an absolute path])])
+AS_IF([test -z "$PYTHON"], [PYTHON="python"])
+AS_IF([echo "$PYTHON" | grep -q "^/"], [], [PYTHON=`type -p "$PYTHON"`])
+PYTHONPATH=$PYTHON
+PYTHON=`basename $PYTHONPATH`
+
 AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON])
 AX_CHECK_PYTHON_VERSION([2], [6])
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 25 lines · Ian Jackson

./configure takes a PYTHON=... argument. You can use this to specify the python interpreter. However, for no good reason, it expects an absolute path.

Fix this. The new logic is:
* if not set, default to `python'
* if not absolute, look it up with type -p
* split into directory and executable name

The results in config/Tools.mk (which contains @PYTHON@ and @PYTHONPATH@) are identical for both
./configure
./configure PYTHON=/usr/bin/python
so I assert this has no functional change except that now you can say
./configure PYTHON=python

In particular you can now say
./configure PYTHON=python2
./configure PYTHON=python3

The latter is useful if you want python3 (which should probably be the default, but does not work right now). The former is useful if you want python2 but your distro has foolishly made "python" refer to python3.

Quoted 4 lines
CC Doug Goldstein <[email protected]>
CC Wei Liu <[email protected]>
CC George Dunlap <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel