Skip to content

Commit 015f2c4

Browse files
committed
chore(librarian): Remove all python runtimes except 3.14
1 parent c0baa32 commit 015f2c4

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

.generator/Dockerfile

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,27 @@ RUN apt-get update && \
3636
&& apt-get clean && \
3737
rm -rf /var/lib/apt/lists/*
3838

39-
# Install multiple Python versions from source. `make altinstall` is used to
40-
# prevent replacing the system's default python binary.
41-
# TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10.18` when the linked issue is resolved.
42-
RUN for PYTHON_VERSION in 3.9.23 3.10.18 3.13.7 3.14.0; do \
43-
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
44-
tar -xvf Python-${PYTHON_VERSION}.tgz && \
45-
cd Python-${PYTHON_VERSION} && \
39+
ENV PYTHON_VERSION=3.14
40+
41+
# The full Python version, including the minor version, is needed for download/install
42+
ENV PYTHON_VERSION_WITH_MINOR=3.14.0
43+
44+
# `make altinstall` is used to prevent replacing the system's default python binary.
45+
RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION_WITH_MINOR}/Python-${PYTHON_VERSION_WITH_MINOR}.tgz && \
46+
tar -xvf Python-${PYTHON_VERSION_WITH_MINOR}.tgz && \
47+
cd Python-${PYTHON_VERSION_WITH_MINOR} && \
4648
./configure --enable-optimizations --prefix=/usr/local && \
4749
make -j$(nproc) && \
4850
make altinstall && \
4951
cd / && \
50-
rm -rf Python-${PYTHON_VERSION}* \
51-
; done
52+
rm -rf Python-${PYTHON_VERSION_WITH_MINOR}*
5253

5354
# Install pip for each python version
5455
# TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10` when the linked issue is resolved.
5556
RUN wget --no-check-certificate -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' && \
56-
for PYTHON_VERSION in 3.9 3.10 3.13 3.14; do \
57-
python${PYTHON_VERSION} /tmp/get-pip.py; \
58-
done && \
57+
python${PYTHON_VERSION} /tmp/get-pip.py && \
5958
rm /tmp/get-pip.py
6059

61-
RUN /usr/local/bin/python3.9 -m venv bazel_env
62-
RUN . bazel_env/bin/activate
63-
6460
# Download/extract protoc
6561
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-linux-x86_64.zip
6662
RUN unzip protoc-25.3-linux-x86_64.zip -d protoc
@@ -73,8 +69,7 @@ RUN wget https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pando
7369
RUN tar -xvf pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz -C pandoc-binary --strip-components=1
7470

7571
# Pin synthtool for a more hermetic build
76-
RUN git clone https://github.com/googleapis/synthtool.git synthtool
77-
RUN cd synthtool && git checkout 35313ccd8cdd2d12d2447ccdc497a7919aae1e3e
72+
RUN git clone https://github.com/googleapis/synthtool.git synthtool && cd synthtool && git checkout 35313ccd8cdd2d12d2447ccdc497a7919aae1e3e
7873

7974
# --- Final Stage ---
8075
# This stage creates the lightweight final image, copying only the
@@ -85,6 +80,8 @@ FROM marketplace.gcr.io/google/ubuntu2404
8580
# the live repo.
8681
ENV SYNTHTOOL_TEMPLATES="/synthtool/synthtool/gcp/templates"
8782

83+
ENV PYTHON_VERSION=3.14
84+
8885
# Install only the essential runtime libraries for Python.
8986
# These are the non "-dev" versions of the libraries used in the builder.
9087
RUN apt-get update && \
@@ -104,19 +101,8 @@ COPY --from=builder protoc/include /usr/local/include
104101
COPY --from=builder pandoc-binary/bin /usr/local/bin
105102
COPY --from=builder synthtool /synthtool
106103

107-
# Copy all Python interpreters, their pip executables, and their standard libraries from the builder.
108-
COPY --from=builder /usr/local/bin/python3.9 /usr/local/bin/
109-
COPY --from=builder /usr/local/lib/python3.9 /usr/local/lib/python3.9
110-
111-
# TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10` when the linked issue is resolved.
112-
COPY --from=builder /usr/local/bin/python3.10 /usr/local/bin/
113-
COPY --from=builder /usr/local/lib/python3.10 /usr/local/lib/python3.10
114-
115-
COPY --from=builder /usr/local/bin/python3.13 /usr/local/bin/
116-
COPY --from=builder /usr/local/lib/python3.13 /usr/local/lib/python3.13
117-
118-
COPY --from=builder /usr/local/bin/python3.14 /usr/local/bin/
119-
COPY --from=builder /usr/local/lib/python3.14 /usr/local/lib/python3.14
104+
COPY --from=builder /usr/local/bin/python${PYTHON_VERSION} /usr/local/bin/
105+
COPY --from=builder /usr/local/lib/python${PYTHON_VERSION} /usr/local/lib/python${PYTHON_VERSION}
120106

121107
# Set the working directory in the container.
122108
WORKDIR /app
@@ -126,12 +112,12 @@ WORKDIR /app
126112
# Install nox which is used for running client library tests.
127113
# Install starlark-pyo3 which is used to parse BUILD.bazel files.
128114
COPY .generator/requirements.in .
129-
RUN python3.9 -m pip install -r requirements.in
130-
RUN python3.9 -m pip install /synthtool
115+
RUN python${PYTHON_VERSION} -m pip install -r requirements.in
116+
RUN python${PYTHON_VERSION} -m pip install /synthtool
131117

132118
# Install build which is used to get the metadata of package config files.
133119
COPY .generator/requirements.in .
134-
RUN python3.9 -m pip install -r requirements.in
120+
RUN python${PYTHON_VERSION} -m pip install -r requirements.in
135121

136122
# Copy the CLI script into the container.
137123
COPY .generator/cli.py .
@@ -141,4 +127,4 @@ RUN chmod a+rx ./cli.py
141127
COPY .generator/parse_googleapis_content.py .
142128
RUN chmod a+rx ./parse_googleapis_content.py
143129

144-
ENTRYPOINT ["python3.9", "./cli.py"]
130+
ENTRYPOINT ["python3.14", "./cli.py"]

.generator/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ def _run_nox_sessions(library_id: str, repo: str):
875875
the config.yaml.
876876
"""
877877
sessions = [
878-
"unit-3.13(protobuf_implementation='upb')",
878+
"unit-3.14(protobuf_implementation='upb')",
879879
]
880880
current_session = None
881881
try:

0 commit comments

Comments
 (0)