Commit 75fef513 authored by Laurent Bachelier's avatar Laurent Bachelier 🐧

tools: Factorize Python detection code

parent ad9382f4
VER=2
if [ "$1" = -3 ]; then
VER=3
shift
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)
fi
fi
#!/bin/sh
set -e
VER=2
if [ "$1" = -3 ]; then
VER=3
shift
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)
fi
fi
. "$(dirname $0)/common.sh"
$PYTHON "$(dirname $0)/stale_pyc.py"
......
#!/bin/sh
set -e
VER=2
if [ "$1" = -3 ]; then
VER=3
shift
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)
fi
fi
. "$(dirname $0)/common.sh"
$PYTHON "$(dirname $0)/stale_pyc.py"
......
......@@ -3,23 +3,7 @@
# stop on failure
set -e
VER=2
if [ "$1" = -3 ]; then
VER=3
shift
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)
fi
fi
. "$(dirname $0)/common.sh"
# Use C local to avoid local dates in headers
export LANG=en_US.utf8
......
......@@ -10,12 +10,19 @@
# stop on failure
set -e
VER=2
if [ "$1" = -3 ]; then
VER=3
shift
. "$(dirname $0)/common.sh"
if [ -z "${PYTHON}" ]; then
echo "Python required"
exit 1
fi
if ! $PYTHON -c "import nose" 2>/dev/null; then
echo "python-nose required"
exit 1
fi
# path to sources
WEBOOB_DIR=$(cd $(dirname $0)/.. && pwd -P)
......@@ -61,30 +68,6 @@ else
WEBOOB_CI_TARGET=""
fi
# find executables
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)
fi
fi
if [ -z "${PYTHON}" ]; then
echo "Python required"
exit 1
fi
if ! $PYTHON -c "import nose" 2>/dev/null; then
echo "python-nose required"
exit 1
fi
# do not allow undefined variables anymore
set -u
if [ -f "${WEBOOB_BACKENDS}" ]; then
......
......@@ -3,23 +3,7 @@
# stop on failure
set -e
VER=2
if [ "$1" = -3 ]; then
VER=3
shift
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)
fi
fi
. "$(dirname $0)/common.sh"
[ -z "${TMPDIR}" ] && TMPDIR="/tmp"
......
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