diff mbox series

[v3,3/3] xen/build: Automatically locate a suitable python interpreter

Message ID 20191207211634.9958-4-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show
Series xen: Build fixes related to Python3 | expand

Commit Message

Andrew Cooper Dec. 7, 2019, 9:16 p.m. UTC
Needing to pass PYTHON=python3 into hypervisor builds is irritating and
unnecessary.  Locate a suitable interpreter automatically, defaulting to Py3
if it is available.

Reported-by: Steven Haigh <netwiz@crc.id.au>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Ian Jackson <ian.jackson@citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Wei Liu <wl@xen.org>
CC: Julien Grall <julien@xen.org>
CC: Steven Haigh <netwiz@crc.id.au>
CC: Juergen Gross <jgross@suse.com>

v2:
 * Cope with `which` not being present in the system.
 * Only evaulate the shell command one, rather than once per $(PTHON) usage

For 4.13.  This is a very-nice-to-have WRT our Py3-clean intention.
---
 xen/Makefile | 5 +++++
 1 file changed, 5 insertions(+)

Comments

George Dunlap Dec. 9, 2019, 11 a.m. UTC | #1
On 12/7/19 9:16 PM, Andrew Cooper wrote:
> Needing to pass PYTHON=python3 into hypervisor builds is irritating and
> unnecessary.  Locate a suitable interpreter automatically, defaulting to Py3
> if it is available.
> 
> Reported-by: Steven Haigh <netwiz@crc.id.au>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: George Dunlap <George.Dunlap@eu.citrix.com>
> CC: Ian Jackson <ian.jackson@citrix.com>
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Wei Liu <wl@xen.org>
> CC: Julien Grall <julien@xen.org>
> CC: Steven Haigh <netwiz@crc.id.au>
> CC: Juergen Gross <jgross@suse.com>
> 
> v2:
>  * Cope with `which` not being present in the system.
>  * Only evaulate the shell command one, rather than once per $(PTHON) usage
> 
> For 4.13.  This is a very-nice-to-have WRT our Py3-clean intention.
> ---
>  xen/Makefile | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/xen/Makefile b/xen/Makefile
> index 949ca6eb03..f36a5bc6c0 100644
> --- a/xen/Makefile
> +++ b/xen/Makefile
> @@ -13,6 +13,11 @@ export XEN_BUILD_TIME	?= $(shell LC_ALL=C date +%T)
>  export XEN_BUILD_HOST	?= $(shell hostname)
>  export XEN_CONFIG_EXPERT ?= n
>  
> +# Best effort attempt to find a python interpreter, defaulting to Python 3 if
> +# available.  Fall back to just `python` if `which` is nowhere to be found.
> +PYTHON_INTERPRETER	:= $(word 1,$(shell which python3 python python2 2>/dev/null) python)
> +export PYTHON		?= $(PYTHON_INTERPRETER)

Acked-by: George Dunlap <george.dunlap@citrix.com>
Jürgen Groß Dec. 10, 2019, 12:45 p.m. UTC | #2
On 07.12.19 22:16, Andrew Cooper wrote:
> Needing to pass PYTHON=python3 into hypervisor builds is irritating and
> unnecessary.  Locate a suitable interpreter automatically, defaulting to Py3
> if it is available.
> 
> Reported-by: Steven Haigh <netwiz@crc.id.au>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Release-acked-by: Juergen Gross <jgross@suse.com>


Juergen
diff mbox series

Patch

diff --git a/xen/Makefile b/xen/Makefile
index 949ca6eb03..f36a5bc6c0 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -13,6 +13,11 @@  export XEN_BUILD_TIME	?= $(shell LC_ALL=C date +%T)
 export XEN_BUILD_HOST	?= $(shell hostname)
 export XEN_CONFIG_EXPERT ?= n
 
+# Best effort attempt to find a python interpreter, defaulting to Python 3 if
+# available.  Fall back to just `python` if `which` is nowhere to be found.
+PYTHON_INTERPRETER	:= $(word 1,$(shell which python3 python python2 2>/dev/null) python)
+export PYTHON		?= $(PYTHON_INTERPRETER)
+
 export BASEDIR := $(CURDIR)
 export XEN_ROOT := $(BASEDIR)/..