Skip to content

Commit

Permalink
fix bug in install_python_venv (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
akaranjkar-qu authored Jun 10, 2020
1 parent d30caf4 commit 46a050c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions misc/python_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,23 @@
#
# @arg $1 float Version of Python to use. Defaults to 3.6
# @arg $2 string Location to create virtualenv in. Defaults to /usr/lib/virtualenv/py36
#
# @exitcode 0 Python virtualenv was created and activated
# @exitcode 1 Python executable for virtualenv couldn't be found or installed
function install_python_venv() {
version=${$1:-36}
location=${$2:-/usr/lib/virtualenv/py36}
version=${1:-36}
location=${2:-/usr/lib/virtualenv/py36}

if [[ ! -x /usr/bin/python${version} ]]; then
echo "No executable /usr/bin/python${version} found. Attempting to install.."
yum_python_package=${version//.}
yum install -y "python${yum_python_package}"
if [[ $? -ne 0 ]]; then
echo "Failed to install python${version}.."
return 1
fi
fi

yum install -y "python${version}"
mkdir -p $location

virtualenv -p "/usr/bin/python${version}" $location
Expand Down

0 comments on commit 46a050c

Please sign in to comment.