diff mbox series

[PATCH-for-4.13] build: fix tools/configure in case only python3 exists

Message ID 20191211165659.29939-1-jgross@suse.com (mailing list archive)
State New, archived
Headers show
Series [PATCH-for-4.13] build: fix tools/configure in case only python3 exists | expand

Commit Message

Juergen Gross Dec. 11, 2019, 4:56 p.m. UTC
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().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/configure.ac | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Wei Liu Dec. 12, 2019, 12:03 p.m. UTC | #1
On Wed, Dec 11, 2019 at 05:56:59PM +0100, Juergen Gross wrote:
> 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().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Acked-by: Wei Liu <wl@xen.org>
Ian Jackson Dec. 12, 2019, 2:11 p.m. UTC | #2
Thanks for tidying this up.

Juergen Gross writes ("[PATCH-for-4.13] build: fix tools/configure in case only python3 exists"):
> -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.

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

Thanks.

Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>

Ian.
Wei Liu Dec. 12, 2019, 2:15 p.m. UTC | #3
On Thu, Dec 12, 2019 at 02:11:32PM +0000, Ian Jackson wrote:
> Thanks for tidying this up.
> 
> Juergen Gross writes ("[PATCH-for-4.13] build: fix tools/configure in case only python3 exists"):
> > -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.
> 
> > +AS_IF([echo "$PYTHON" | grep -q "^/"], [], [AC_PATH_PROG([PYTHON], [$PYTHON])])
> 
> Thanks.
> 
> Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>

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

Wei.

> 
> Ian.
diff mbox series

Patch

diff --git a/tools/configure.ac b/tools/configure.ac
index a8d8ce5ffe..8d86c42de8 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -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`