Unverified Commit d2316628 authored by Vatsal Gupta's avatar Vatsal Gupta Committed by GitHub

Fix: Handle case where Python version is already installed (#222) (#1115)

* Fix: Handle case where Python version is already installed in dev container (#617)

* Incorporated Review Comment: Version exist handling
parent 68871f5c
......@@ -465,16 +465,18 @@ install_prev_vers_cpython() {
install_cpython() {
VERSION=$1
INSTALL_PATH="${PYTHON_INSTALL_PATH}/${VERSION}"
# Check if the specified Python version is already installed
if [ -d "${INSTALL_PATH}" ]; then
echo "(!) Python version ${VERSION} already exists."
exit 1
fi
else
mkdir -p /tmp/python-src ${INSTALL_PATH}
cd /tmp/python-src
cpython_tgz_filename="Python-${VERSION}.tgz"
cpython_tgz_url="https://www.python.org/ftp/python/${VERSION}/${cpython_tgz_filename}"
echo "Downloading ${cpython_tgz_filename}..."
curl -sSL -o "/tmp/python-src/${cpython_tgz_filename}" "${cpython_tgz_url}"
fi
}
install_from_source() {
......@@ -560,11 +562,10 @@ install_using_oryx() {
VERSION=$1
INSTALL_PATH="${PYTHON_INSTALL_PATH}/${VERSION}"
# Check if the specified Python version is already installed
if [ -d "${INSTALL_PATH}" ]; then
echo "(!) Python version ${VERSION} already exists."
exit 1
fi
else
# The python install root path may not exist, so create it
mkdir -p "${PYTHON_INSTALL_PATH}"
oryx_install "python" "${VERSION}" "${INSTALL_PATH}" "lib" || return 1
......@@ -574,6 +575,7 @@ install_using_oryx() {
ln -s "${INSTALL_PATH}/bin/python3-config" "${INSTALL_PATH}/bin/python-config"
add_symlink
fi
}
sudo_if() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment