Skip to content

Commit 8dd373b

Browse files
committed
Update "chutney" shell script to search only for python 3.
1 parent 743939a commit 8dd373b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

chutney

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ then
1212
export CHUTNEY_PATH
1313
fi
1414

15-
binaries="python3 python python2"
15+
python_ok ()
16+
{
17+
checkpy="$1"
18+
test -f "${checkpy}" && \
19+
test -x "${checkpy}" && \
20+
"${checkpy}" -c 'import sys;sys.exit(sys.version_info[0]<3)'
21+
}
22+
23+
binaries="python3 python"
1624

1725
if ! test "${PYTHON+y}"
1826
then
@@ -31,7 +39,7 @@ then
3139
;;
3240
esac
3341
abs_path="${directory}${binary}"
34-
if test -f "${abs_path}" && test -x "${abs_path}"
42+
if python_ok "${abs_path}"
3543
then
3644
PYTHON="${abs_path}"
3745
break
@@ -44,12 +52,18 @@ then
4452
fi
4553
done
4654
IFS="${saved_IFS}"
55+
else
56+
if ! python_ok "$(command -v "${PYTHON}")"
57+
then
58+
echo "Python in \$PYTHON envvar (\"$PYTHON\") is not present, or is not python 3." >&2
59+
exit 1
60+
fi
4761
fi
4862

4963
if ! test "${PYTHON+y}"
5064
then
5165
printf "No compatible Python version found.\n" >&2
52-
printf "Is Python installed and in your PATH?\n" >&2
66+
printf "Is python 3 installed and in your PATH?\n" >&2
5367
exit 1
5468
fi
5569

0 commit comments

Comments
 (0)