@@ -110,33 +110,68 @@ RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
110110 && rm -rf /var/lib/apt/lists/* \
111111 && rm -f /var/cache/apt/archives/*.deb
112112
113- COPY fetch_gpg_keys.sh /tmp
114- # Install the desired versions of Python.
115- RUN set -ex \
116- && export GNUPGHOME="$(mktemp -d)" \
117- && echo "disable-ipv6" >> "${GNUPGHOME}/dirmngr.conf" \
118- && /tmp/fetch_gpg_keys.sh \
119- && for PYTHON_VERSION in 2.7.18 3.7.17 3.8.20 3.9.20 3.10.15 3.11.10 3.12.7 3.13.0; do \
120- wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
121- && wget --no-check-certificate -O python-${PYTHON_VERSION}.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
122- && gpg --batch --verify python-${PYTHON_VERSION}.tar.xz.asc python-${PYTHON_VERSION}.tar.xz \
123- && rm -r python-${PYTHON_VERSION}.tar.xz.asc \
124- && mkdir -p /usr/src/python-${PYTHON_VERSION} \
125- && tar -xJC /usr/src/python-${PYTHON_VERSION} --strip-components=1 -f python-${PYTHON_VERSION}.tar.xz \
126- && rm python-${PYTHON_VERSION}.tar.xz \
127- && cd /usr/src/python-${PYTHON_VERSION} \
128- && ./configure \
129- --enable-shared \
130- # This works only on Python 2.7 and throws a warning on every other
131- # version, but seems otherwise harmless.
132- --enable-unicode=ucs4 \
133- --with-system-ffi \
134- --without-ensurepip \
135- && make -j$(nproc) \
136- && make install \
137- && ldconfig \
113+ # From https://www.python.org/downloads/metadata/sigstore/
114+ # Starting with Python 3.14, Sigstore is the only method of signing and verification of release artifacts.
115+ RUN LATEST_VERSION="2.6.1" && \
116+ wget "https://github.com/sigstore/cosign/releases/download/v${LATEST_VERSION}/cosign_${LATEST_VERSION}_amd64.deb" && \
117+ dpkg -i cosign_${LATEST_VERSION}_amd64.deb && \
118+ rm cosign_${LATEST_VERSION}_amd64.deb
119+
120+ ARG PYTHON_VERSIONS="3.7.17 3.8.20 3.9.23 3.10.18 3.11.13 3.12.11 3.13.8 3.14.0"
121+
122+ SHELL ["/bin/bash" , "-c" ]
123+
124+ RUN set -eux; \
125+ # Define the required associative arrays completely.
126+ declare -A PYTHON_IDENTITIES; \
127+ PYTHON_IDENTITIES=(\
128+ [3.7]="nad@python.org" \
129+ [3.8]="lukasz@langa.pl" \
130+ [3.9]="lukasz@langa.pl" \
131+ [3.10]="pablogsal@python.org" \
132+ [3.11]="pablogsal@python.org" \
133+ [3.12]="thomas@python.org" \
134+ [3.13]="thomas@python.org" \
135+ [3.14]="hugo@python.org" \
136+ ); \
137+ declare -A PYTHON_ISSUERS; \
138+ PYTHON_ISSUERS=(\
139+ [3.7]="https://github.com/login/oauth" \
140+ [3.8]="https://github.com/login/oauth" \
141+ [3.9]="https://github.com/login/oauth" \
142+ [3.10]="https://accounts.google.com" \
143+ [3.11]="https://accounts.google.com" \
144+ [3.12]="https://accounts.google.com" \
145+ [3.13]="https://accounts.google.com" \
146+ [3.14]="https://github.com/login/oauth" \
147+ ); \
148+ \
149+ for VERSION in $PYTHON_VERSIONS; do \
150+ # 1. Define VERSION_GROUP (e.g., 3.14 from 3.14.0)
151+ VERSION_GROUP="$(echo " ${VERSION}" | cut -d . -f 1,2)" ; \
152+ \
153+ # 2. Look up IDENTITY and ISSUER using the defined VERSION_GROUP
154+ IDENTITY="${PYTHON_IDENTITIES[$VERSION_GROUP]}" ; \
155+ ISSUER="${PYTHON_ISSUERS[$VERSION_GROUP]}" ; \
156+ \
157+ wget --quiet -O python-${VERSION}.tar.xz "https://www.python.org/ftp/python/${VERSION}/Python-$VERSION.tar.xz" \
158+ && wget --quiet -O python-${VERSION}.tar.xz.sigstore "https://www.python.org/ftp/python/${VERSION}/Python-$VERSION.tar.xz.sigstore" \
159+ # Verify the Python tarball signature with cosign.
160+ && cosign verify-blob python-${VERSION}.tar.xz \
161+ --certificate-oidc-issuer "${ISSUER}" \
162+ --certificate-identity "${IDENTITY}" \
163+ --bundle python-${VERSION}.tar.xz.sigstore \
164+ && mkdir -p /usr/src/python-${VERSION} \
165+ && tar -xJC /usr/src/python-${VERSION} --strip-components=1 -f python-${VERSION}.tar.xz \
166+ && rm python-${VERSION}.tar.xz \
167+ && cd /usr/src/python-${VERSION} \
168+ && ./configure \
169+ --enable-shared \
170+ --with-system-ffi \
171+ && make -j$(nproc) \
172+ && make install \
173+ && ldconfig \
138174 ; done \
139- && rm -rf "${GNUPGHOME}" \
140175 && rm -rf /usr/src/python* \
141176 && rm -rf ~/.cache/
142177
@@ -158,6 +193,7 @@ RUN wget --no-check-certificate -O /tmp/get-pip-3-7.py 'https://bootstrap.pypa.i
158193 && [ "$(pip list |tac|tac| awk -F '[ ()]+' '$1 == " pip" { print $2; exit }')" = "$PYTHON_PIP_VERSION" ]
159194
160195# Ensure Pip for all python3 versions
196+ RUN python3.14 /tmp/get-pip.py
161197RUN python3.13 /tmp/get-pip.py
162198RUN python3.12 /tmp/get-pip.py
163199RUN python3.11 /tmp/get-pip.py
@@ -175,6 +211,7 @@ RUN python3.10 -m pip
175211RUN python3.11 -m pip
176212RUN python3.12 -m pip
177213RUN python3.13 -m pip
214+ RUN python3.14 -m pip
178215
179216# Install "setuptools" for Python 3.12+ (see https://docs.python.org/3/whatsnew/3.12.html#distutils)
180217RUN python3.12 -m pip install --no-cache-dir setuptools
0 commit comments