Skip to content

Commit 3020d6d

Browse files
authored
Fix python feature issue devcontainers#258, improve tests, fix oryx bug (devcontainers#261)
* Fix devcontainers#258, improve tests, fix oryx bug * Drop Debian 9 from tests given it is out of support
1 parent 73a9c7d commit 3020d6d

12 files changed

Lines changed: 137 additions & 17 deletions

.devcontainer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
"features": {
1212
"ghcr.io/devcontainers/features/docker-in-docker:1": {}
1313
},
14-
"postCreateCommand": "npm install -g @devcontainers/cli"
14+
"postCreateCommand": "npm install -g @devcontainers/cli",
15+
"hostRequirements": {
16+
"cpus": 4
17+
}
1518
}

.github/workflows/test-all.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ jobs:
4747
"ubuntu:bionic",
4848
"debian:11",
4949
"debian:10",
50-
"debian:9",
5150
"mcr.microsoft.com/devcontainers/base:ubuntu",
5251
"mcr.microsoft.com/devcontainers/base:debian",
5352
]

.github/workflows/test-pr.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ jobs:
5454
"ubuntu:bionic",
5555
"debian:11",
5656
"debian:10",
57-
"debian:9",
5857
"mcr.microsoft.com/devcontainers/base:ubuntu",
5958
"mcr.microsoft.com/devcontainers/base:debian",
6059
]

src/python/devcontainer-feature.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "python",
3-
"version": "1.0.10",
3+
"version": "1.0.11",
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.",
@@ -60,7 +60,7 @@
6060
"ms-python.vscode-pylance"
6161
],
6262
"settings": {
63-
"python.defaultInterpreterPath": "/usr/local/bin/python",
63+
"python.defaultInterpreterPath": "/usr/local/python/current/bin/python",
6464
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
6565
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
6666
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
@@ -74,6 +74,7 @@
7474
}
7575
},
7676
"installsAfter": [
77-
"ghcr.io/devcontainers/features/common-utils"
77+
"ghcr.io/devcontainers/features/common-utils",
78+
"ghcr.io/devcontainers/features/oryx"
7879
]
7980
}

src/python/install.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ install_using_oryx() {
299299
echo "(!) Python version ${VERSION} already exists."
300300
exit 1
301301
fi
302+
303+
# The python install root path may not exist, so create it
304+
mkdir -p "${PYTHON_INSTALL_PATH}"
302305
oryx_install "python" "${VERSION}" "${INSTALL_PATH}" "lib" || return 1
303306

304307
ln -s "${INSTALL_PATH}/bin/idle3" "${INSTALL_PATH}/bin/idle"
@@ -339,11 +342,15 @@ install_python() {
339342
# If the os-provided versions are "good enough", detect that and bail out.
340343
if [ ${PYTHON_VERSION} = "os-provided" ] || [ ${PYTHON_VERSION} = "system" ]; then
341344
check_packages python3 python3-doc python3-pip python3-venv python3-dev python3-tk
342-
PYTHON_ROOT="/usr/bin"
345+
INSTALL_PATH="/usr"
346+
347+
ln -s "${INSTALL_PATH}/bin/python3" "${INSTALL_PATH}/bin/python"
348+
ln -s "${INSTALL_PATH}/bin/pydoc3" "${INSTALL_PATH}/bin/pydoc"
349+
ln -s "${INSTALL_PATH}/bin/python3-config" "${INSTALL_PATH}/bin/python-config"
343350

344-
ln -s "${PYTHON_ROOT}/python3" "${PYTHON_ROOT}/python"
345-
ln -s "${PYTHON_ROOT}/pydoc3" "${PYTHON_ROOT}/pydoc"
346-
ln -s "${PYTHON_ROOT}/python3-config" "${PYTHON_ROOT}/python-config"
351+
# Add the current symlink but point it to "/usr" since python is at /usr/bin/python
352+
mkdir -p "${PYTHON_INSTALL_PATH}"
353+
add_symlink
347354

348355
should_install_from_source=false
349356
elif [ "$(dpkg --print-architecture)" = "amd64" ] && [ "${USE_ORYX_IF_AVAILABLE}" = "true" ] && type oryx > /dev/null 2>&1; then

test/python/install_additional_jupyterlab.sh

100644100755
File mode changed.

test/python/install_additional_python.sh

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

8-
check "python version 3.11 installed as default" python --version | grep 3.11
9-
check "python3 version 3.11 installed as default" python3 --version | grep 3.11
10-
check "python version 3.10.5 installed" ls -l /usr/local/python | grep 3.10.5
11-
check "python version 3.8.13 installed" ls -l /usr/local/python | grep 3.8.13
12-
check "python version 3.9.13 installed" ls -l /usr/local/python | grep 3.9.13
8+
check "python version 3.11 installed as default" bash -c "python --version | grep 3.11"
9+
check "python3 version 3.11 installed as default" bash -c "python3 --version | grep 3.11"
10+
check "python version 3.10.5 installed" bash -c "ls -l /usr/local/python | grep 3.10.5"
11+
check "python version 3.8 installed" bash -c "ls -l /usr/local/python | grep 3.8"
12+
check "python version 3.9.13 installed" bash -c "ls -l /usr/local/python | grep 3.9.13"
13+
14+
# Check that tools can execute - make sure something didn't get messed up in this scenario
15+
check "autopep8" autopep8 --version
16+
check "black" black --version
17+
check "yapf" yapf --version
18+
check "bandit" bandit --version
19+
check "flake8" flake8 --version
20+
check "mypy" mypy --version
21+
check "pycodestyle" pycodestyle --version
22+
check "pydocstyle" pydocstyle --version
23+
check "pylint" pylint --version
24+
25+
# Check paths in settings
26+
check "current symlink is correct" bash -c "which python | grep /usr/local/python/current/bin/python"
27+
check "which autopep8" bash -c "which autopep8 | grep /usr/local/py-utils/bin/autopep8"
28+
check "which black" bash -c "which black | grep /usr/local/py-utils/bin/black"
29+
check "which yapf" bash -c "which yapf | grep /usr/local/py-utils/bin/yapf"
30+
check "which bandit" bash -c "which bandit | grep /usr/local/py-utils/bin/bandit"
31+
check "which flake8" bash -c "which flake8 | grep /usr/local/py-utils/bin/flake8"
32+
check "which mypy" bash -c "which mypy | grep /usr/local/py-utils/bin/mypy"
33+
check "which pycodestyle" bash -c "which pycodestyle | grep /usr/local/py-utils/bin/pycodestyle"
34+
check "which pydocstyle" bash -c "which pydocstyle | grep /usr/local/py-utils/bin/pydocstyle"
35+
check "which pylint" bash -c "which pylint | grep /usr/local/py-utils/bin/pylint"
1336

1437
# Report result
1538
reportResults

test/python/install_jupyterlab.sh

100644100755
File mode changed.

test/python/install_os_provided_python.sh

100644100755
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,28 @@ check "python is installed" python --version
1010
check "pip is installed" pip --version
1111
check "pip is installed" pip3 --version
1212

13-
check "node is installed" node --version
13+
# Check that tools can execute
14+
check "autopep8" autopep8 --version
15+
check "black" black --version
16+
check "yapf" yapf --version
17+
check "bandit" bandit --version
18+
check "flake8" flake8 --version
19+
check "mypy" mypy --version
20+
check "pycodestyle" pycodestyle --version
21+
check "pydocstyle" pydocstyle --version
22+
check "pylint" pylint --version
23+
24+
# Check paths in settings
25+
check "current symlink is correct" bash -c "which python | grep /usr/local/python/current/bin/python"
26+
check "which autopep8" bash -c "which autopep8 | grep /usr/local/py-utils/bin/autopep8"
27+
check "which black" bash -c "which black | grep /usr/local/py-utils/bin/black"
28+
check "which yapf" bash -c "which yapf | grep /usr/local/py-utils/bin/yapf"
29+
check "which bandit" bash -c "which bandit | grep /usr/local/py-utils/bin/bandit"
30+
check "which flake8" bash -c "which flake8 | grep /usr/local/py-utils/bin/flake8"
31+
check "which mypy" bash -c "which mypy | grep /usr/local/py-utils/bin/mypy"
32+
check "which pycodestyle" bash -c "which pycodestyle | grep /usr/local/py-utils/bin/pycodestyle"
33+
check "which pydocstyle" bash -c "which pydocstyle | grep /usr/local/py-utils/bin/pydocstyle"
34+
check "which pylint" bash -c "which pylint | grep /usr/local/py-utils/bin/pylint"
1435

1536
# Report result
1637
reportResults

test/python/install_via_oryx.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library
6+
source dev-container-features-test-lib
7+
8+
check "python3 is installed" python3 --version
9+
check "python is installed" python --version
10+
check "pip is installed" pip --version
11+
check "pip is installed" pip3 --version
12+
13+
# Check that tools can execute
14+
check "autopep8" autopep8 --version
15+
check "black" black --version
16+
check "yapf" yapf --version
17+
check "bandit" bandit --version
18+
check "flake8" flake8 --version
19+
check "mypy" mypy --version
20+
check "pycodestyle" pycodestyle --version
21+
check "pydocstyle" pydocstyle --version
22+
check "pylint" pylint --version
23+
24+
# Check paths in settings
25+
check "current symlink is correct" bash -c "which python | grep /usr/local/python/current/bin/python"
26+
check "which autopep8" bash -c "which autopep8 | grep /usr/local/py-utils/bin/autopep8"
27+
check "which black" bash -c "which black | grep /usr/local/py-utils/bin/black"
28+
check "which yapf" bash -c "which yapf | grep /usr/local/py-utils/bin/yapf"
29+
check "which bandit" bash -c "which bandit | grep /usr/local/py-utils/bin/bandit"
30+
check "which flake8" bash -c "which flake8 | grep /usr/local/py-utils/bin/flake8"
31+
check "which mypy" bash -c "which mypy | grep /usr/local/py-utils/bin/mypy"
32+
check "which pycodestyle" bash -c "which pycodestyle | grep /usr/local/py-utils/bin/pycodestyle"
33+
check "which pydocstyle" bash -c "which pydocstyle | grep /usr/local/py-utils/bin/pydocstyle"
34+
check "which pylint" bash -c "which pylint | grep /usr/local/py-utils/bin/pylint"
35+
36+
# Report result
37+
reportResults

0 commit comments

Comments
 (0)