Skip to content

Commit

Permalink
INSTALL: detecting if the venv is outdated to support better python v…
Browse files Browse the repository at this point in the history
…ersion upgrades (usually through OS upgrades)
  • Loading branch information
Commit-La-Grenouille committed Mar 25, 2022
1 parent d82d00b commit be823f2
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,37 @@ fi
cd ${root_dir}
if [ -x "$(command -v python3.9)" ] ; then
python=python3.9
if [ ! -d "venv" ]; then
echo "Creating Python 3.9 virtual environment"
${python} -m venv venv
fi
pyvers="3.9"
elif [ -x "$(command -v python3.7)" ] ; then
python=python3.7
if [ ! -d "venv" ]; then
echo "Creating Python 3.7 virtual environment"
${python} -m venv venv
fi
pyvers="3.7"
else
echo "Please install Python 3.7 or 3.9 (you might need to upgrade your Linux distribution)"
exit 1
fi

# Common venv management code
if [ ! -d "venv" ]; then
echo "Creating Python ${pyvers} virtual environment"
${python} -m venv venv
else
# Checking which version of python was used to create the existing venv
if [ -e "venv/bin/python3.9" ]; then
venv_vers=python3.9
elif [ -e "venv/bin/python3.7" ]; then
venv_vers=python3.7
else
# Attempting a blind detection of whatever unexpected version there could be
venv_vers=$(ls -1 venv/bin/python3.?)
fi

if [ "${venv_vers}" != "${python}" ]; then
echo "Replacing Python ${venv_vers} virtual environment with version ${pyvers}"
rm -fr venv
${python} -m venv venv
fi
fi

echo "Installing PyPi requirements"
if [ $upgrade -eq 1 ]; then
echo "Updating Python requirements - 7/14" > /tmp/pynab.upgrade
Expand Down

0 comments on commit be823f2

Please sign in to comment.