Resolve Python2.7 when executable is not called 'python'.
authorJostein Kjønigsen <jostein@kjonigsen.net>
Thu, 7 Jul 2016 08:49:20 +0000 (10:49 +0200)
committerJostein Kjønigsen <jostein@kjonigsen.net>
Fri, 8 Jul 2016 07:34:31 +0000 (09:34 +0200)
build.sh

index fe4c0b01ce602b66f354a53dd818047c04e9e6ae..0d9af84fa1eb0c1491c3f7bda08acd4e964d81c5 100755 (executable)
--- 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()
 {