commit 8dd373ba78d8aaa191273bcbea277d1df25ed43d Author: Nick Mathewson nickm@torproject.org Date: Thu Jul 9 14:58:25 2020 -0400
Update "chutney" shell script to search only for python 3. --- chutney | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/chutney b/chutney index 63f9a47..b53e2d0 100755 --- a/chutney +++ b/chutney @@ -12,7 +12,15 @@ then export CHUTNEY_PATH fi
-binaries="python3 python python2" +python_ok () +{ + checkpy="$1" + test -f "${checkpy}" && \ + test -x "${checkpy}" && \ + "${checkpy}" -c 'import sys;sys.exit(sys.version_info[0]<3)' +} + +binaries="python3 python"
if ! test "${PYTHON+y}" then @@ -31,7 +39,7 @@ then ;; esac abs_path="${directory}${binary}" - if test -f "${abs_path}" && test -x "${abs_path}" + if python_ok "${abs_path}" then PYTHON="${abs_path}" break @@ -44,12 +52,18 @@ then fi done IFS="${saved_IFS}" +else + if ! python_ok "$(command -v "${PYTHON}")" + then + echo "Python in $PYTHON envvar ("$PYTHON") is not present, or is not python 3." >&2 + exit 1 + fi fi
if ! test "${PYTHON+y}" then printf "No compatible Python version found.\n" >&2 - printf "Is Python installed and in your PATH?\n" >&2 + printf "Is python 3 installed and in your PATH?\n" >&2 exit 1 fi
tor-commits@lists.torproject.org