From: Andrew Cooper Date: Thu, 1 Jul 2021 12:12:34 +0000 (+0100) Subject: build: Fix build when only python3 is available X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=cdef9568c1b1f8831f3b8f644073e635d47f0ec4;p=xtf.git build: Fix build when only python3 is available The shebang lines in the python scrips - xtf-runner in particular - still need work, but this at least fixes `make` on systems without `python` on $PATH. Default to python3 in CI too. Reported-by: Pranjal Singh <008pranjalsingh@gmail.com> Signed-off-by: Andrew Cooper Tested-by: Pranjal Singh <008pranjalsingh@gmail.com> --- diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e27db63..b0c84e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: esac sudo apt-get update -q - sudo apt-get install -y build-essential python ${{matrix.compiler}} ${EXTRA} + sudo apt-get install -y build-essential python3 ${{matrix.compiler}} ${EXTRA} - uses: actions/checkout@v2 diff --git a/Makefile b/Makefile index a7af201..9195957 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,11 @@ INSTALL := install INSTALL_DATA := $(INSTALL) -m 644 -p INSTALL_DIR := $(INSTALL) -d -p INSTALL_PROGRAM := $(INSTALL) -p -PYTHON := python + +# 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) +PYTHON ?= $(PYTHON_INTERPRETER) export CC LD CPP INSTALL INSTALL_DATA INSTALL_DIR INSTALL_PROGRAM OBJCOPY PYTHON