Skip to content

Commit a9e71e6

Browse files
[universal] Bump Python SDK versions (devcontainers#831)
* Bump Python SDKs versions - v3.10: 3.10.8 -> 3.10.13 - v3.9: 3.9.16 -> 3.9.18 * [patch-conda] Remove outdated patches * [patch-python] Remove outdated patches * [patch-python/patch-conda] Add `pip show` command * [test-utils] Update `checkPythonPackageVersion` function to make it generic * [patch-python] Rework `update_package` feature
1 parent 0ce3c38 commit a9e71e6

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

src/universal/.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
},
2424
"./local-features/nvs": "latest",
2525
"ghcr.io/devcontainers/features/python:1": {
26-
"version": "3.10.8",
27-
"additionalVersions": "3.9.16",
26+
"version": "3.10.13",
27+
"additionalVersions": "3.9.18",
2828
"installJupyterlab": "true",
2929
"configureJupyterlabAllowOrigin": "*",
3030
"useOryxIfAvailable": "false"

src/universal/.devcontainer/local-features/patch-conda/install.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ update_python_package() {
3636

3737
sudo_if "$PYTHON_PATH -m pip uninstall --yes $PACKAGE"
3838
sudo_if "$PYTHON_PATH -m pip install --upgrade --no-cache-dir $PACKAGE==$VERSION"
39+
sudo_if "$PYTHON_PATH -m pip show --no-python-version-warning $PACKAGE"
3940
}
4041

4142
update_conda_package() {
@@ -50,14 +51,8 @@ sudo_if /opt/conda/bin/python3 -m pip install --upgrade pip
5051
# Temporary: Upgrade python packages due to security vulnerabilities
5152
# They are installed by the conda feature and Conda distribution does not have the patches.
5253

53-
# pyopenssl should be updated to be compatible with latest version of cryptography
54-
update_conda_package pyopenssl "23.2.0"
55-
5654
# https://github.com/advisories/GHSA-v8gr-m533-ghj9
5755
update_python_package /opt/conda/bin/python3 cryptography "41.0.4"
5856

59-
# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-32681
60-
update_conda_package requests "2.31.0"
61-
6257
# https://github.com/advisories/GHSA-v845-jxx5-vc9f
6358
update_conda_package urllib3 "1.26.18"

src/universal/.devcontainer/local-features/patch-python/install.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,15 @@ sudo_if() {
3232
update_package() {
3333
PYTHON_PATH=$1
3434
PACKAGE=$2
35+
VERSION=$3
3536

3637
sudo_if "$PYTHON_PATH -m pip uninstall --yes $PACKAGE"
37-
sudo_if "$PYTHON_PATH -m pip install --upgrade --no-cache-dir $PACKAGE"
38+
sudo_if "$PYTHON_PATH -m pip install --upgrade --no-cache-dir $PACKAGE==$VERSION"
39+
sudo_if "$PYTHON_PATH -m pip show --no-python-version-warning $PACKAGE"
3840
}
3941

4042
# Temporary: Upgrade python packages due to security vulnerabilities
4143
# They are installed by the base image (python) which does not have the patch.
4244

4345
# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40897
44-
update_package /usr/local/python/3.9.*/bin/python setuptools==65.5.1
45-
update_package /usr/local/python/3.10.*/bin/python setuptools==68.0.0
46-
47-
# https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-32681
48-
update_package /usr/local/python/3.10.*/bin/python requests==2.31.0
46+
update_package /usr/local/python/3.9.*/bin/python setuptools 65.5.1

src/universal/test-project/test-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ checkPythonPackageVersion()
224224
PACKAGE=$2
225225
REQUIRED_VERSION=$3
226226

227-
current_version=$(${PYTHON_PATH} -c "import ${PACKAGE}; print(${PACKAGE}.__version__)")
227+
current_version=$(${PYTHON_PATH} -c "import importlib.metadata; print(importlib.metadata.version('${PACKAGE}'))")
228228
check-version-ge "${PACKAGE}-requirement" "${current_version}" "${REQUIRED_VERSION}"
229229
}
230230

0 commit comments

Comments
 (0)