From f7ce899294d259a768d9099a563df378234d3369 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Mon, 7 Oct 2024 20:27:05 +0100 Subject: Ensure Python versions ending in t are installed to a dir ending in t The t denotes that it is a free threading version of Python, so could potentially be installed along side a non-free-threaded version of Python --- Dockerfile | 1 - scripts/build_python.sh | 14 +++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index f68b789..051b275 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,6 @@ FROM builder-py-base as builder-py-3_13t # --disable-test-modules --enable-optimizations --with-lto ENV PYTHON_CONFIGURE_OPTS='--enable-optimizations --with-lto --with-system-expat --without-ensurepip' RUN /build_python.sh 3.13.0rc3t -RUN mv /snekbin/python/3.13 /snekbin/python/3.13t # ------------------------------------------------------------------------------ FROM python:3.12-slim-bookworm as base diff --git a/scripts/build_python.sh b/scripts/build_python.sh index 77f50ab..ea3f6d8 100755 --- a/scripts/build_python.sh +++ b/scripts/build_python.sh @@ -4,11 +4,19 @@ shopt -s inherit_errexit py_version="${1}" -# Install Python interpreter under e.g. /snekbin/python/3.11/ (no patch version). +# Install Python interpreter under e.g. /snekbin/python/3.13/ (no patch version) +# By dropping everything after, and including, the last period. +install_path="${1%[-.]*}" + +# If python version ends with a t, then ensure Python is installed to a dir ending with a t. +if [[ $py_version == *t ]]; then + install_path+="t" +fi + "${PYENV_ROOT}/plugins/python-build/bin/python-build" \ "${py_version}" \ - "/snekbin/python/${py_version%[-.]*}" -"/snekbin/python/${py_version%[-.]*}/bin/python" -m pip install -U pip + "/snekbin/python/${install_path}" +"/snekbin/python/${install_path}/bin/python" -m pip install -U pip # Clean up some unnecessary files to reduce image size bloat. find /snekbin/python/ -depth \ -- cgit v1.2.3