diff --git a/tools/common.sh b/tools/common.sh new file mode 100644 index 0000000000000000000000000000000000000000..74870d03496ae3183c2d2da66bdcb4adbda33860 --- /dev/null +++ b/tools/common.sh @@ -0,0 +1,17 @@ +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 diff --git a/tools/local_install.sh b/tools/local_install.sh index 34d3b97f3c7672c9a402cf189150f30c3ee26de6..f723b47039d727238864ab63454b9cbb8dbb22af 100755 --- a/tools/local_install.sh +++ b/tools/local_install.sh @@ -1,23 +1,7 @@ #!/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" diff --git a/tools/local_run.sh b/tools/local_run.sh index 5fb19dd6407a91d749437d302564536634979ce1..12d245fec8cd59324b1e7b5a983e282b82e71c0b 100755 --- a/tools/local_run.sh +++ b/tools/local_run.sh @@ -1,23 +1,7 @@ #!/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" diff --git a/tools/make_man.sh b/tools/make_man.sh index ede9a4980cf3b69740ad800af612040a4d1871ea..f343cf31b8ad742f2c5595fc6ae9f3802a963fc5 100755 --- a/tools/make_man.sh +++ b/tools/make_man.sh @@ -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 diff --git a/tools/run_tests.sh b/tools/run_tests.sh index 2dac9bc8e235e46b9600f6e492d62f4d768fdd69..6964296f26f35135e16139a470aadae80715b6d2 100755 --- a/tools/run_tests.sh +++ b/tools/run_tests.sh @@ -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 diff --git a/tools/weboob_lint.sh b/tools/weboob_lint.sh index 1628b12e74bfc32f6958e4a173a3697e8fef728e..0aecba52d792aa7d46c8544822c00a5c47ebf115 100755 --- a/tools/weboob_lint.sh +++ b/tools/weboob_lint.sh @@ -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"