Commit 1b4a7486 authored by Laurent Bachelier's avatar Laurent Bachelier 🐧
Browse files

tools: More powerful Python detection

Fill PYTHON2 and PYTHON3 variables. Allow override of everything.
Favor the generic version name because we expect the "better"
python2/python3 version to be set by the distribution.
parent 75fef513
VER=2
if [ "$1" = -3 ]; then
if [ "${1-}" = "-3" ]; then
VER=3
shift
fi
if [ -z "${PYTHON}" ]; then
if [ -z "${PYTHON2-}" ]; then
which python2.7 >/dev/null 2>&1 && PYTHON2=$(which python2.7)
which python2 >/dev/null 2>&1 && PYTHON2=$(which python2)
fi
if [ -z "${PYTHON3-}" ]; then
which python3.4 >/dev/null 2>&1 && PYTHON3=$(which python3.4)
which python3.5 >/dev/null 2>&1 && PYTHON3=$(which python3.5)
which python3.6 >/dev/null 2>&1 && PYTHON3=$(which python3.6)
which python3 >/dev/null 2>&1 && PYTHON3=$(which python3)
fi
if [ -z "${PYTHON-}" ]; then
which python >/dev/null 2>&1 && PYTHON=$(which python)
which python$VER >/dev/null 2>&1 && PYTHON=$(which python$VER)
if [ $VER -eq 2 ]; then
which python2.7 >/dev/null 2>&1 && PYTHON=$(which python2.7)
else
which python3.4 >/dev/null 2>&1 && PYTHON=$(which python3.4)
which python3.5 >/dev/null 2>&1 && PYTHON=$(which python3.5)
which python3.6 >/dev/null 2>&1 && PYTHON=$(which python3.6)
if [ $VER -eq 2 -a -n "${PYTHON2}" ]; then
PYTHON=${PYTHON2}
elif [ $VER -eq 3 -a -n "${PYTHON3}" ]; then
PYTHON=${PYTHON3}
fi
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment