From aec899b73efb7f71201bc9789ab28a72d2cfb29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Fri, 3 May 2019 11:36:26 -0400 Subject: [PATCH] configure: automatically pick python3 is available Unless overridden via an env var or configure arg, QEMU will only look for the 'python' binary in $PATH. This is unhelpful on distros which are only shipping Python 3.x (eg Fedora) in their default install as, if they comply with PEP 394, the bare 'python' binary won't exist. This changes configure so that by default it will search for all three common python binaries, preferring to find Python 3.x versions. Backports commit faf441429adfe5767be52c5dcdb8bc03161d064f from qemu --- qemu/configure | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/qemu/configure b/qemu/configure index 39a035e0..0e8b74df 100755 --- a/qemu/configure +++ b/qemu/configure @@ -484,7 +484,18 @@ Linux) esac : ${make=${MAKE-make}} -: ${python=${PYTHON-python}} +# We prefer python 3.x. A bare 'python' is traditionally +# python 2.x, but some distros have it as python 3.x, so +# we check that before python2 +python= +for binary in "${PYTHON-python3}" python python2 +do + if has "$binary" + then + python="$binary" + break + fi +done # Default objcc to clang if available, otherwise use CC if has clang; then @@ -579,8 +590,9 @@ done # Remove old dependency files to make sure that they get properly regenerated rm -f *-config-devices.mak.d -if ! has $python; then - error_exit "Python not found. Use --python=/path/to/python" +if test -z "$python" +then + error_exit "Python not found. Use --python=/path/to/python" fi # Note that if the Python conditional here evaluates True we will exit