Unverified Commit f9acb6aa authored by Samruddhi Khandale's avatar Samruddhi Khandale Committed by GitHub

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
parent a5655189
{ {
"id": "python", "id": "python",
"version": "1.0.13", "version": "1.0.14",
"name": "Python", "name": "Python",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/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.", "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.",
......
...@@ -322,7 +322,7 @@ sudo_if() { ...@@ -322,7 +322,7 @@ sudo_if() {
install_user_package() { install_user_package() {
PACKAGE="$1" 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() { add_user_jupyter_config() {
...@@ -408,11 +408,15 @@ if [ "${PYTHON_VERSION}" != "none" ]; then ...@@ -408,11 +408,15 @@ if [ "${PYTHON_VERSION}" != "none" ]; then
updaterc "if [[ \"\${PATH}\" != *\"${CURRENT_PATH}/bin\"* ]]; then export PATH=${CURRENT_PATH}/bin:\${PATH}; fi" updaterc "if [[ \"\${PATH}\" != *\"${CURRENT_PATH}/bin\"* ]]; then export PATH=${CURRENT_PATH}/bin:\${PATH}; fi"
PATH="${INSTALL_PATH}/bin:${PATH}" PATH="${INSTALL_PATH}/bin:${PATH}"
fi fi
# Updates the symlinks for os-provided, or the installed python version in other cases # Updates the symlinks for os-provided, or the installed python version in other cases
chown -R "${USERNAME}:python" "${PYTHON_INSTALL_PATH}" chown -R "${USERNAME}:python" "${PYTHON_INSTALL_PATH}"
chmod -R g+r+w "${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 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 fi
# Install Python tools if needed # Install Python tools if needed
...@@ -464,6 +468,11 @@ fi ...@@ -464,6 +468,11 @@ fi
# Install JupyterLab if needed # Install JupyterLab if needed
if [ "${INSTALL_JUPYTERLAB}" = "true" ]; then 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
install_user_package jupyterlab-git install_user_package jupyterlab-git
......
#!/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
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
"remoteUser": "vscode", "remoteUser": "vscode",
"features": { "features": {
"python": { "python": {
"version": "latest",
"installJupyterlab": true, "installJupyterlab": true,
"configureJupyterlabAllowOrigin": "*" "configureJupyterlabAllowOrigin": "*"
} }
...@@ -36,6 +37,17 @@ ...@@ -36,6 +37,17 @@
"python": "os-provided" "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": { "install_via_oryx": {
"image": "mcr.microsoft.com/oryx/build:full-debian-bullseye", "image": "mcr.microsoft.com/oryx/build:full-debian-bullseye",
"features": { "features": {
......
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