]> xenbits.xensource.com Git - people/andrewcoop/xen-test-framework.git/commitdiff
build: Fix build when only python3 is available
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 1 Jul 2021 12:12:34 +0000 (13:12 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 1 Jul 2021 12:28:25 +0000 (13:28 +0100)
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 <andrew.cooper3@citrix.com>
Tested-by: Pranjal Singh <008pranjalsingh@gmail.com>
.github/workflows/build.yml
Makefile

index e27db631383476e2e398134175f60f2dd3fda548..b0c84e4333ba3d1bad133f67203e98699627ff76 100644 (file)
@@ -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
 
index a7af201ebae93aaeb70d6cbaa02c180d466639dd..919595737db2c7c13be8bee8320238c719b2fa2f 100644 (file)
--- 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