Skip to contentSkip to conversation

build: fix tools/configure in case only python3 exists

Xen-devel Juergen Gross 3 participants 4 messages Dec 11, 2019 – Dec 12, 2019

lore
Share & tools
lore
#0 lore raw

Calling ./configure with python3 being there but no python, tools/configure will fail. Fix that by defaulting to python and falling back to python3 or python2.

While at it fix the use of non portable "type -p" by replacing it by AC_PATH_PROG().

---
 tools/configure.ac | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/configure.ac +3 -2
index a8d8ce5ffe..8d86c42de8 100644
@@ -337,8 +337,9 @@ case "$host_os" in
   freebsd*) ;;
   *) AX_PATH_PROG_OR_FAIL([BASH], [bash]);;
 esac
-AS_IF([test -z "$PYTHON"], [PYTHON="python"])
-AS_IF([echo "$PYTHON" | grep -q "^/"], [], [PYTHON=`type -p "$PYTHON"`])
+AS_IF([test -z "$PYTHON"], [AC_CHECK_PROGS([PYTHON], [python python3 python2], err)])
+AS_IF([test "$PYTHON" = "err"], [AC_MSG_ERROR([No python interpreter found])])
+AS_IF([echo "$PYTHON" | grep -q "^/"], [], [AC_PATH_PROG([PYTHON], [$PYTHON])])
 PYTHONPATH=$PYTHON
 PYTHON=`basename $PYTHONPATH`
 
Signature · 7 lines
2.16.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by
#1 lore raw
Quoted 8 lines · Juergen Gross

Calling ./configure with python3 being there but no python, tools/configure will fail. Fix that by defaulting to python and falling back to python3 or python2.

While at it fix the use of non portable "type -p" by replacing it by AC_PATH_PROG().

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

Reviewed-by
#2 lore raw
In reply to Juergen Gross

Thanks for tidying this up.

Juergen Gross writes ("[PATCH-for-4.13] build: fix tools/configure in case only python3 exists"):

tools/configure.ac case "$host_os" in · line 341

Quoted 4 lines
tools/configure.ac +2 -2
-AS_IF([test -z "$PYTHON"], [PYTHON="python"])
-AS_IF([echo "$PYTHON" | grep -q "^/"], [], [PYTHON=`type -p "$PYTHON"`])
+AS_IF([test -z "$PYTHON"], [AC_CHECK_PROGS([PYTHON], [python python3 python2], err)])
+AS_IF([test "$PYTHON" = "err"], [AC_MSG_ERROR([No python interpreter found])])

I think this use of `err' is a bit odd. According to the FM you could say simply:

+AS_IF([test -z "$PYTHON"], [AC_CHECK_PROGS([PYTHON], [python python3 python2])]) +AS_IF([test -z "$PYTHON"], [AC_MSG_ERROR([No python interpreter found])])

But this is a style nit I think since no-one will call their python interpreter `err' :-). And you will have tested your version and at this stage of 4.13 it would be better to have fewer iterations of this patch, so I think it should go in as it is.

Quoted 1 line

+AS_IF([echo "$PYTHON" | grep -q "^/"], [], [AC_PATH_PROG([PYTHON], [$PYTHON])])

Thanks.

Ian.

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

#3 lore raw
Quoted 19 lines · Ian Jackson

Thanks for tidying this up.

Juergen Gross writes ("[PATCH-for-4.13] build: fix tools/configure in case only python3 exists"):

tools/configure.ac case "$host_os" in · line 341

Quoted 4 lines
tools/configure.ac +2 -2
-AS_IF([test -z "$PYTHON"], [PYTHON="python"])
-AS_IF([echo "$PYTHON" | grep -q "^/"], [], [PYTHON=`type -p "$PYTHON"`])
+AS_IF([test -z "$PYTHON"], [AC_CHECK_PROGS([PYTHON], [python python3 python2], err)])
+AS_IF([test "$PYTHON" = "err"], [AC_MSG_ERROR([No python interpreter found])])

I think this use of `err' is a bit odd. According to the FM you could say simply:

+AS_IF([test -z "$PYTHON"], [AC_CHECK_PROGS([PYTHON], [python python3 python2])]) +AS_IF([test -z "$PYTHON"], [AC_MSG_ERROR([No python interpreter found])])

But this is a style nit I think since no-one will call their python interpreter `err' :-). And you will have tested your version and at this stage of 4.13 it would be better to have fewer iterations of this patch, so I think it should go in as it is.

Quoted 5 lines
Quoted 1 line

+AS_IF([echo "$PYTHON" | grep -q "^/"], [], [AC_PATH_PROG([PYTHON], [$PYTHON])])

Thanks.

Thanks. I will push this to staging and staging-4.13 shortly.

Wei.

Quoted 2 lines

Ian.

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