From 92a6cc4ae278d6c0f57f3353d7f94f3c14484b66 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 12 Feb 2019 12:12:32 +0100 Subject: [PATCH] Updating update-env.sh to use minimal Python version 3.5 --- update-env.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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 -- 2.39.5