Browse Source

If $PYTHON isn't set, use python2 or python

If $PYTHON isn't set, use "command" to check for python2, then python.
(python3 check is disabled due to #16904 - chutney doesn't work with
python3.)

If neither of the "command" checks work, assume a strange shell or "command",
and fall back to python2.

Fixes default install of chutney on OS X, which has neither $PYTHON set,
nor python2; but does have python, which happens to be version 2.

Resolves #16902.
teor (Tim Wilson-Brown) 8 years ago
parent
commit
2a3b01ff68
1 changed files with 8 additions and 0 deletions
  1. 8 0
      chutney

+ 8 - 0
chutney

@@ -1,4 +1,12 @@
 #!/bin/sh
 
 export PYTHONPATH="`dirname $0`/lib:${PYTHONPATH}"
+# Use python2, python, python3 in that order
+[ -n "$PYTHON" ] || {
+    command -v python2 >/dev/null 2>&1 && PYTHON=python2 || \
+    command -v python >/dev/null 2>&1 && PYTHON=python # || \
+#   Not yet supported 
+#   command -v python3 >/dev/null 2>&1 && PYTHON=python3
+}
+# Use python2 if the checks that use "command" fail
 ${PYTHON:=python2} -m chutney.TorNet "$@"