Skip to content

Commit 960f21c

Browse files
authored
Fix additional Python and JupyterLab edge case (#182)
* Remove bloat from JupyterLab test * Check location of JupyterLab installation * Remove common-utils * Add failing additional with JL test * Fix Python feature * Update scenario images * Bump patch version
1 parent 8c19bb1 commit 960f21c

5 files changed

Lines changed: 50 additions & 9 deletions

File tree

src/python/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "python",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"name": "Python",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/python",
66
"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.",

src/python/install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,15 @@ if [ "${PYTHON_VERSION}" != "none" ]; then
374374

375375
# Additional python versions to be installed but not be set as default.
376376
if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
377+
OLD_INSTALL_PATH="${INSTALL_PATH}"
377378
OLDIFS=$IFS
378379
IFS=","
379380
read -a additional_versions <<< "$ADDITIONAL_VERSIONS"
380381
for version in "${additional_versions[@]}"; do
381382
OVERRIDE_DEFAULT_VERSION="false"
382383
install_python $version
383384
done
385+
INSTALL_PATH="${OLD_INSTALL_PATH}"
384386
IFS=$OLDIFS
385387
fi
386388

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
# Always run these checks as the non-root user
9+
user="$(whoami)"
10+
check "user" grep vscode <<< "$user"
11+
12+
# Check for an installation of JupyterLab
13+
check "version" jupyter lab --version
14+
15+
# Check location of JupyterLab installation
16+
packages="$(python3 -m pip list)"
17+
check "location" grep jupyter <<< "$packages"
18+
19+
# Check for correct JupyterLab configuration
20+
check "config" grep ".*.allow_origin = '*'" /home/vscode/.jupyter/jupyter_server_config.py
21+
22+
# Report result
23+
reportResults

test/python/install_jupyterlab.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8+
# Always run these checks as the non-root user
9+
user="$(whoami)"
10+
check "user" grep vscode <<< "$user"
11+
12+
# Check for an installation of JupyterLab
813
check "version" jupyter lab --version
9-
check "config" grep ".*.allow_origin = '*'" /home/vscode/.jupyter/jupyter_server_config.py
1014

11-
check "user" whoami | grep vscode
12-
check "zsh" zsh --version
13-
check "wget" wget -V
15+
# Check location of JupyterLab installation
16+
packages="$(python3 -m pip list)"
17+
check "location" grep jupyter <<< "$packages"
18+
19+
# Check for correct JupyterLab configuration
20+
check "config" grep ".*.allow_origin = '*'" /home/vscode/.jupyter/jupyter_server_config.py
1421

1522
# Report result
1623
reportResults

test/python/scenarios.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,27 @@
99
}
1010
},
1111
"install_jupyterlab": {
12-
"image": "mcr.microsoft.com/vscode/devcontainers/base:focal",
12+
"image": "mcr.microsoft.com/devcontainers/base:focal",
1313
"remoteUser": "vscode",
1414
"features": {
15-
"common-utils": {
16-
"username": "vscode"
17-
},
1815
"python": {
1916
"installJupyterlab": true,
2017
"configureJupyterlabAllowOrigin": "*"
2118
}
2219
}
2320
},
21+
"install_additional_jupyterlab": {
22+
"image": "mcr.microsoft.com/devcontainers/base:focal",
23+
"remoteUser": "vscode",
24+
"features": {
25+
"python": {
26+
"version": "latest",
27+
"additionalVersions": "3.9",
28+
"installJupyterlab": true,
29+
"configureJupyterlabAllowOrigin": "*"
30+
}
31+
}
32+
},
2433
"install_os_provided_python": {
2534
"image": "mcr.microsoft.com/devcontainers/base:0-bullseye",
2635
"features": {

0 commit comments

Comments
 (0)