diff --git a/setup_env b/setup_env index 3b45878..4017052 100755 --- a/setup_env +++ b/setup_env @@ -44,6 +44,8 @@ while getopts c:p:t:qs:h FLAG; do p) if [ ${OPTARG} == '2' ]; then PY_VERSION="2.7.8" + elif [ ${OPTARG} == '3' ]; then + PY_VERSION=${PY_VERSION} else PY_VERSION=${OPTARG} fi @@ -168,8 +170,12 @@ fi # Build local python interpreter if needed sub_pystr="python$(echo $PY_VERSION | cut -c 1-3)" -if [ ! -n "$(command -v $sub_pystr)" ]; then - echo "$sub_pystr not found. Building python ${PY_VERSION}..." +python_version=$($sub_pystr -V | cut -d " " -f 2) +if [ $python_version == $PY_VERSION ]; then + echo "Python $PY_VERSION found!" + PYPATH="$sub_pystr" +else + echo "Python $PY_VERSION not found. Building python ${PY_VERSION}..." mkdir ${WORKDIR}/.localpython mkdir ${WORKDIR}/.python_src cd ${WORKDIR}/.python_src @@ -182,9 +188,6 @@ if [ ! -n "$(command -v $sub_pystr)" ]; then cd ${WORKDIR} rm -rf ${WORKDIR}/.python_src PYPATH="${WORKDIR}/.localpython/bin/$sub_pystr" -else - echo "$sub_pystr found!" - PYPATH="$sub_pystr" fi # Setup virtual environments for refstack-client and tempest