From: Frank Brehm Date: Tue, 12 Feb 2019 11:12:32 +0000 (+0100) Subject: Updating update-env.sh to use minimal Python version 3.5 X-Git-Tag: 1.6.4^2~61 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=92a6cc4ae278d6c0f57f3353d7f94f3c14484b66;p=pixelpark%2Fpuppetmaster-webhooks.git Updating update-env.sh to use minimal Python version 3.5 --- diff --git a/update-env.sh b/update-env.sh index e952f3c..7f3f6e3 100755 --- a/update-env.sh +++ b/update-env.sh @@ -1,9 +1,33 @@ #!/bin/bash -echo "Preparing virtual environment ..." +base_dir=$( dirname $0 ) +cd ${base_dir} +base_dir=$( readlink -f . ) + +declare -a VALID_PY_VERSIONS=("3.8" "3.7" "3.6" "3.5") + +echo "Preparing virtual environment …" echo if [[ ! -f venv/bin/activate ]] ; then - virtualenv --python=python3 venv + found="n" + for py_version in "${VALID_PY_VERSIONS[@]}" ; do + PYTHON="python${py_version}" + if type -t ${PYTHON} >/dev/null ; then + found="y" + echo + echo "Found ${PYTHON}." + echo + virtualenv --python=${PYTHON} venv + break + fi + done + if [[ "${found}" == "n" ]] ; then + echo >&2 + echo "Did not found a usable Python version." >&2 + echo "Usable Python versions are: ${VALID_PY_VERSIONS[*]}" >&2 + echo >&2 + exit 5 + fi fi . venv/bin/activate || exit 5