diff options
author | Samruddhi Khandale <skhandale@microsoft.com> | 2022-11-16 00:26:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-16 00:26:26 +0300 |
commit | f9acb6aae1e520b0b61aaac9ab4ecb00dd497451 (patch) | |
tree | ee6c4e60efa56f52b6258f40d0b663da06b690a9 | |
parent | a5655189a24b04fc43f4ae9dcae0be5acf1b9ecb (diff) |
Python bug fix - Add jupyterlab even if python is not installed by Feature but exists (#244)
* python fix bug
* fix test
* address comments
* address comment
-rw-r--r-- | src/python/devcontainer-feature.json | 2 | ||||
-rwxr-xr-x | src/python/install.sh | 13 | ||||
-rw-r--r-- | test/python/install_jupyterlab_from_python_image.sh | 16 | ||||
-rw-r--r-- | test/python/scenarios.json | 12 |
4 files changed, 40 insertions, 3 deletions
diff --git a/src/python/devcontainer-feature.json b/src/python/devcontainer-feature.json index c1bcdc6..fbbf62c 100644 --- a/src/python/devcontainer-feature.json +++ b/src/python/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "python", - "version": "1.0.13", + "version": "1.0.14", "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.", diff --git a/src/python/install.sh b/src/python/install.sh index 93d9cce..79ab7de 100755 --- a/src/python/install.sh +++ b/src/python/install.sh @@ -322,7 +322,7 @@ sudo_if() { install_user_package() { PACKAGE="$1" - sudo_if "$INSTALL_PATH/bin/python3" -m pip install --user --upgrade --no-cache-dir "$PACKAGE" + sudo_if "${PYTHON_SRC}" -m pip install --user --upgrade --no-cache-dir "$PACKAGE" } add_user_jupyter_config() { @@ -408,11 +408,15 @@ if [ "${PYTHON_VERSION}" != "none" ]; then updaterc "if [[ \"\${PATH}\" != *\"${CURRENT_PATH}/bin\"* ]]; then export PATH=${CURRENT_PATH}/bin:\${PATH}; fi" PATH="${INSTALL_PATH}/bin:${PATH}" fi - + # Updates the symlinks for os-provided, or the installed python version in other cases chown -R "${USERNAME}:python" "${PYTHON_INSTALL_PATH}" chmod -R g+r+w "${PYTHON_INSTALL_PATH}" find "${PYTHON_INSTALL_PATH}" -type d -print0 | xargs -0 -n 1 chmod g+s + + PYTHON_SRC="${INSTALL_PATH}/bin/python3" +else + PYTHON_SRC=$(which python) fi # Install Python tools if needed @@ -464,6 +468,11 @@ fi # Install JupyterLab if needed if [ "${INSTALL_JUPYTERLAB}" = "true" ]; then + if [ -z "${PYTHON_SRC}" ]; then + echo "(!) Could not install Jupyterlab. Python not found." + exit 1 + fi + install_user_package jupyterlab install_user_package jupyterlab-git diff --git a/test/python/install_jupyterlab_from_python_image.sh b/test/python/install_jupyterlab_from_python_image.sh new file mode 100644 index 0000000..067046b --- /dev/null +++ b/test/python/install_jupyterlab_from_python_image.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +# Always run these checks as the non-root user +user="$(whoami)" +check "user" grep vscode <<< "$user" + +# Check for an installation of JupyterLab +check "version" jupyter lab --version + +# Report result +reportResults diff --git a/test/python/scenarios.json b/test/python/scenarios.json index 920f4a2..c3c1a82 100644 --- a/test/python/scenarios.json +++ b/test/python/scenarios.json @@ -13,6 +13,7 @@ "remoteUser": "vscode", "features": { "python": { + "version": "latest", "installJupyterlab": true, "configureJupyterlabAllowOrigin": "*" } @@ -36,6 +37,17 @@ "python": "os-provided" } }, + "install_jupyterlab_from_python_image": { + "image": "mcr.microsoft.com/devcontainers/python:3.10-bullseye", + "remoteUser": "vscode", + "features": { + "python": { + "version": "none", + "installTools": false, + "installJupyterlab": true + } + } + }, "install_via_oryx": { "image": "mcr.microsoft.com/oryx/build:full-debian-bullseye", "features": { |