@@ -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.
5556RUN 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
6561RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-linux-x86_64.zip
6662RUN unzip protoc-25.3-linux-x86_64.zip -d protoc
@@ -85,6 +81,8 @@ FROM marketplace.gcr.io/google/ubuntu2404
8581# the live repo.
8682ENV SYNTHTOOL_TEMPLATES="/synthtool/synthtool/gcp/templates"
8783
84+ ENV PYTHON_VERSION=3.14
85+
8886# Install only the essential runtime libraries for Python.
8987# These are the non "-dev" versions of the libraries used in the builder.
9088RUN apt-get update && \
@@ -104,19 +102,8 @@ COPY --from=builder protoc/include /usr/local/include
104102COPY --from=builder pandoc-binary/bin /usr/local/bin
105103COPY --from=builder synthtool /synthtool
106104
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
105+ COPY --from=builder /usr/local/bin/python${PYTHON_VERSION} /usr/local/bin/
106+ COPY --from=builder /usr/local/lib/python${PYTHON_VERSION} /usr/local/lib/python${PYTHON_VERSION}
120107
121108# Set the working directory in the container.
122109WORKDIR /app
@@ -126,12 +113,12 @@ WORKDIR /app
126113# Install nox which is used for running client library tests.
127114# Install starlark-pyo3 which is used to parse BUILD.bazel files.
128115COPY .generator/requirements.in .
129- RUN python3.9 -m pip install -r requirements.in
130- RUN python3.9 -m pip install /synthtool
116+ RUN python${PYTHON_VERSION} -m pip install -r requirements.in
117+ RUN python${PYTHON_VERSION} -m pip install /synthtool
131118
132119# Install build which is used to get the metadata of package config files.
133120COPY .generator/requirements.in .
134- RUN python3.9 -m pip install -r requirements.in
121+ RUN python${PYTHON_VERSION} -m pip install -r requirements.in
135122
136123# Copy the CLI script into the container.
137124COPY .generator/cli.py .
@@ -141,4 +128,4 @@ RUN chmod a+rx ./cli.py
141128COPY .generator/parse_googleapis_content.py .
142129RUN chmod a+rx ./parse_googleapis_content.py
143130
144- ENTRYPOINT ["python3.9 " , "./cli.py" ]
131+ ENTRYPOINT ["python3.14 " , "./cli.py" ]
0 commit comments