Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue related to the installation of Python #236

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
41 changes: 26 additions & 15 deletions .github/scripts/setup_vdms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,37 @@ else

fi


# SETUP PYTHON VERSION
version_exists=$(echo "$(python${PYTHON_BASE} --version | cut -d ' ' -f 2)" || echo false)
if [ "${version_exists}" != "${PYTHON_VERSION}" ]
# Check the version used by python3
version_exists=$(echo "$(python3 --version | cut -d ' ' -f 2)" || echo false)
version_used_base=""
# if that version is lower than the required one
if $(dpkg --compare-versions "${version_exists}" "lt" "${PYTHON_VERSION}")
then
echo "Installing python ${PYTHON_VERSION}..."
apt update -y
apt install -y libffi-dev libgdbm-dev libnss3-dev libreadline-dev libsqlite3-dev zlib1g-dev
curl -L -o ${VDMS_DEP_DIR}/Python-${PYTHON_VERSION}.tgz https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz
cd ${VDMS_DEP_DIR}
tar -xzf Python-${PYTHON_VERSION}.tgz
cd Python-${PYTHON_VERSION}
./configure --enable-optimizations && make -j && make altinstall
# Check if the path to the required minimum version exists
# if it doesn't exist then it displays the error and finish the script
if [ $(which python${PYTHON_BASE}) = "" ]; then
echo "Error: please install the Python v${PYTHON_VERSION} or greater..."
echo "Exiting..."
# CLEANUP
rm -rf $VDMS_DEP_DIR
exit 1;
fi

# If the required version of Python is installed but it is not being used currently
# Then, the script is going to use at least the version that it is required
version_used_base=${PYTHON_BASE}
else
echo "python ${PYTHON_VERSION} already installed"
# If the current version of Python is equal or greater than the required
echo "$(python3 --version) already installed"
version_used_base=$(echo ${version_exists} | cut -d. -f-2 || echo false)
fi
alias python=$(which python${PYTHON_BASE})
alias python3=$(which python${PYTHON_BASE})

python${PYTHON_BASE} -m venv ${VIRTUAL_ENV}
# It sets the Python version found (3.12 or more recent) as default
alias python=$(which python${version_used_base})
alias python3=$(which python${version_used_base})

python${version_used_base} -m venv ${VIRTUAL_ENV}
export PATH="$VIRTUAL_ENV/bin:$PATH"


Expand Down