diff --git a/.generator/Dockerfile b/.generator/Dockerfile index a419ef0bbecf..b634e01217f9 100644 --- a/.generator/Dockerfile +++ b/.generator/Dockerfile @@ -36,31 +36,27 @@ RUN apt-get update && \ && apt-get clean && \ rm -rf /var/lib/apt/lists/* -# Install multiple Python versions from source. `make altinstall` is used to -# prevent replacing the system's default python binary. -# TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10.18` when the linked issue is resolved. -RUN for PYTHON_VERSION in 3.9.23 3.10.18 3.13.7 3.14.0; do \ - wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \ - tar -xvf Python-${PYTHON_VERSION}.tgz && \ - cd Python-${PYTHON_VERSION} && \ +ENV PYTHON_VERSION=3.14 + +# The full Python version, including the minor version, is needed for download/install +ENV PYTHON_VERSION_WITH_MINOR=3.14.0 + +# `make altinstall` is used to prevent replacing the system's default python binary. +RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION_WITH_MINOR}/Python-${PYTHON_VERSION_WITH_MINOR}.tgz && \ + tar -xvf Python-${PYTHON_VERSION_WITH_MINOR}.tgz && \ + cd Python-${PYTHON_VERSION_WITH_MINOR} && \ ./configure --enable-optimizations --prefix=/usr/local && \ make -j$(nproc) && \ make altinstall && \ cd / && \ - rm -rf Python-${PYTHON_VERSION}* \ - ; done + rm -rf Python-${PYTHON_VERSION_WITH_MINOR}* # Install pip for each python version # TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10` when the linked issue is resolved. RUN wget --no-check-certificate -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' && \ - for PYTHON_VERSION in 3.9 3.10 3.13 3.14; do \ - python${PYTHON_VERSION} /tmp/get-pip.py; \ - done && \ + python${PYTHON_VERSION} /tmp/get-pip.py && \ rm /tmp/get-pip.py -RUN /usr/local/bin/python3.9 -m venv bazel_env -RUN . bazel_env/bin/activate - # Download/extract protoc RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v25.3/protoc-25.3-linux-x86_64.zip RUN unzip protoc-25.3-linux-x86_64.zip -d protoc @@ -85,6 +81,8 @@ FROM marketplace.gcr.io/google/ubuntu2404 # the live repo. ENV SYNTHTOOL_TEMPLATES="/synthtool/synthtool/gcp/templates" +ENV PYTHON_VERSION=3.14 + # Install only the essential runtime libraries for Python. # These are the non "-dev" versions of the libraries used in the builder. RUN apt-get update && \ @@ -104,19 +102,8 @@ COPY --from=builder protoc/include /usr/local/include COPY --from=builder pandoc-binary/bin /usr/local/bin COPY --from=builder synthtool /synthtool -# Copy all Python interpreters, their pip executables, and their standard libraries from the builder. -COPY --from=builder /usr/local/bin/python3.9 /usr/local/bin/ -COPY --from=builder /usr/local/lib/python3.9 /usr/local/lib/python3.9 - -# TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10` when the linked issue is resolved. -COPY --from=builder /usr/local/bin/python3.10 /usr/local/bin/ -COPY --from=builder /usr/local/lib/python3.10 /usr/local/lib/python3.10 - -COPY --from=builder /usr/local/bin/python3.13 /usr/local/bin/ -COPY --from=builder /usr/local/lib/python3.13 /usr/local/lib/python3.13 - -COPY --from=builder /usr/local/bin/python3.14 /usr/local/bin/ -COPY --from=builder /usr/local/lib/python3.14 /usr/local/lib/python3.14 +COPY --from=builder /usr/local/bin/python${PYTHON_VERSION} /usr/local/bin/ +COPY --from=builder /usr/local/lib/python${PYTHON_VERSION} /usr/local/lib/python${PYTHON_VERSION} # Set the working directory in the container. WORKDIR /app @@ -126,12 +113,12 @@ WORKDIR /app # Install nox which is used for running client library tests. # Install starlark-pyo3 which is used to parse BUILD.bazel files. COPY .generator/requirements.in . -RUN python3.9 -m pip install -r requirements.in -RUN python3.9 -m pip install /synthtool +RUN python${PYTHON_VERSION} -m pip install -r requirements.in +RUN python${PYTHON_VERSION} -m pip install /synthtool # Install build which is used to get the metadata of package config files. COPY .generator/requirements.in . -RUN python3.9 -m pip install -r requirements.in +RUN python${PYTHON_VERSION} -m pip install -r requirements.in # Copy the CLI script into the container. COPY .generator/cli.py . @@ -141,4 +128,4 @@ RUN chmod a+rx ./cli.py COPY .generator/parse_googleapis_content.py . RUN chmod a+rx ./parse_googleapis_content.py -ENTRYPOINT ["python3.9", "./cli.py"] +ENTRYPOINT ["python3.14", "./cli.py"] diff --git a/.generator/cli.py b/.generator/cli.py index b200b61a5c6e..38312754d98f 100644 --- a/.generator/cli.py +++ b/.generator/cli.py @@ -875,7 +875,7 @@ def _run_nox_sessions(library_id: str, repo: str): the config.yaml. """ sessions = [ - "unit-3.13(protobuf_implementation='upb')", + "unit-3.14(protobuf_implementation='upb')", ] current_session = None try: diff --git a/.generator/test_cli.py b/.generator/test_cli.py index 69e894c936f0..25f209ed9211 100644 --- a/.generator/test_cli.py +++ b/.generator/test_cli.py @@ -732,7 +732,7 @@ def test_run_nox_sessions_success(mocker, mock_generate_request_data_for_nox): mock_run_individual_session = mocker.patch("cli._run_individual_session") sessions_to_run = [ - "unit-3.13(protobuf_implementation='upb')", + "unit-3.14(protobuf_implementation='upb')", ] _run_nox_sessions("mock-library", "repo") @@ -740,7 +740,7 @@ def test_run_nox_sessions_success(mocker, mock_generate_request_data_for_nox): mock_run_individual_session.assert_has_calls( [ mocker.call( - "unit-3.13(protobuf_implementation='upb')", "mock-library", "repo" + "unit-3.14(protobuf_implementation='upb')", "mock-library", "repo" ), ] )