Skip to content

Commit a4ede5d

Browse files
authored
Fix Python version pin (#2085)
1 parent 8d0ec50 commit a4ede5d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

images/docker-stacks-foundation/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ RUN set -x && \
117117
'jupyter_core' && \
118118
rm -rf /tmp/bin/ && \
119119
# Pin major.minor version of python
120-
mamba list python | grep '^python ' | tr -s ' ' | cut -d ' ' -f 1,2 >> "${CONDA_DIR}/conda-meta/pinned" && \
120+
# https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#preventing-packages-from-updating-pinning
121+
mamba list --full-name 'python' | tail -1 | tr -s ' ' | cut -d ' ' -f 1,2 | sed 's/\.[^.]*$/.*/' >> "${CONDA_DIR}/conda-meta/pinned" && \
121122
mamba clean --all -f -y && \
122123
fix-permissions "${CONDA_DIR}" && \
123124
fix-permissions "/home/${NB_USER}"

tests/docker-stacks-foundation/test_python_version.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@ def test_python_version(container: TrackedContainer) -> None:
2222
major_minor_version = full_version[: full_version.rfind(".")]
2323

2424
assert major_minor_version == EXPECTED_PYTHON_VERSION
25+
26+
27+
def test_python_pinned_version(container: TrackedContainer) -> None:
28+
LOGGER.info(f"Checking that pinned python version is {EXPECTED_PYTHON_VERSION}.*")
29+
logs = container.run_and_wait(
30+
timeout=5,
31+
tty=True,
32+
command=["cat", "/opt/conda/conda-meta/pinned"],
33+
)
34+
assert logs.startswith(f"python {EXPECTED_PYTHON_VERSION}.*")

0 commit comments

Comments
 (0)