From 38c683c17a19bb7119d7334061f18257d9d6ccbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jostein=20Kj=C3=83=C2=B8nigsen?= Date: Thu, 7 Jul 2016 10:49:20 +0200 Subject: [PATCH] Resolve Python2.7 when executable is not called 'python'. --- build.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index fe4c0b01ce60..0d9af84fa1eb 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,29 @@ #!/usr/bin/env bash -PYTHON=${PYTHON:-python} +# resolve python-version to use +if [ "$PYTHON" == "" ] ; then + if which python >/dev/null 2>&1 + then + PYTHON=python + elif which python2 >/dev/null 2>&1 + then + PYTHON=python2 + elif which python2.7 >/dev/null 2>&1 + then + PYTHON=python2.7 + else + echo "Unable to locate build-dependency python2.x!" 1>&2 + exit 1 + fi +fi + +# validate python-dependency +# useful in case of explicitly set option. +if ! which $PYTHON > /dev/null 2>&1 +then + echo "Unable to locate build-dependency python2.x ($PYTHON)!" 1>&2 + exit 1 +fi usage() {