From 0f9b54c9952691010127a8a18301adbefa70be19 Mon Sep 17 00:00:00 2001 From: Vatsal Gupta Date: Wed, 4 Sep 2024 14:05:37 +0530 Subject: [PATCH 1/3] Fix: Handle case where Python version is already installed in dev container (#617) --- src/python/install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/python/install.sh b/src/python/install.sh index 7e30ea041..62360b1d9 100755 --- a/src/python/install.sh +++ b/src/python/install.sh @@ -467,7 +467,6 @@ install_cpython() { INSTALL_PATH="${PYTHON_INSTALL_PATH}/${VERSION}" if [ -d "${INSTALL_PATH}" ]; then echo "(!) Python version ${VERSION} already exists." - exit 1 fi mkdir -p /tmp/python-src ${INSTALL_PATH} cd /tmp/python-src @@ -562,7 +561,6 @@ install_using_oryx() { if [ -d "${INSTALL_PATH}" ]; then echo "(!) Python version ${VERSION} already exists." - exit 1 fi # The python install root path may not exist, so create it From 8175b70d435d2d39bb8570ad23c6d5d27d8172fc Mon Sep 17 00:00:00 2001 From: Vatsal Gupta <40350810+gvatsal60@users.noreply.github.com> Date: Wed, 2 Oct 2024 03:13:53 +0000 Subject: [PATCH 2/3] Incorporated Review Comment: Version exist handling --- src/python/install.sh | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/python/install.sh b/src/python/install.sh index 62360b1d9..ead55cc8a 100755 --- a/src/python/install.sh +++ b/src/python/install.sh @@ -465,15 +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." + 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 - 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}" } install_from_source() { @@ -559,19 +562,20 @@ 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." - fi - - # 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 + 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 - ln -s "${INSTALL_PATH}/bin/idle3" "${INSTALL_PATH}/bin/idle" - ln -s "${INSTALL_PATH}/bin/pydoc3" "${INSTALL_PATH}/bin/pydoc" - ln -s "${INSTALL_PATH}/bin/python3-config" "${INSTALL_PATH}/bin/python-config" + ln -s "${INSTALL_PATH}/bin/idle3" "${INSTALL_PATH}/bin/idle" + ln -s "${INSTALL_PATH}/bin/pydoc3" "${INSTALL_PATH}/bin/pydoc" + ln -s "${INSTALL_PATH}/bin/python3-config" "${INSTALL_PATH}/bin/python-config" - add_symlink + add_symlink + fi } sudo_if() { From 0e6f31b7175a3b60bb5130780a0aaf305db96c3b Mon Sep 17 00:00:00 2001 From: Vatsal Gupta <40350810+gvatsal60@users.noreply.github.com> Date: Sun, 13 Oct 2024 02:25:39 +0000 Subject: [PATCH 3/3] Update: Python Feature Version --- src/python/devcontainer-feature.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/devcontainer-feature.json b/src/python/devcontainer-feature.json index 768cb4388..64b02fd34 100644 --- a/src/python/devcontainer-feature.json +++ b/src/python/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "python", - "version": "1.6.4", + "version": "1.6.5", "name": "Python", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/python", "description": "Installs the provided version of Python, as well as PIPX, and other common Python utilities. JupyterLab is conditionally installed with the python feature. Note: May require source code compilation.",