Skip to content

Commit 6d68146

Browse files
authored
chore(versions): update Python version support to 3.10+ in gapic-generator (#16910)
> [!note] > This PR has been updated to remove 3.7, 3.8, and 3.9 (with one exception discussed below). ### Overview This Pull Request updates the gapic-generator package and related CI configurations to reflect the deprecation of Python 3.7 through 3.9. It updates documentation, templates, and CI scripts to establish Python 3.10 as the new minimum supported version where applicable. ### Changes #### Documentation: * Updated installation and verification instructions in packages/gapic-generator/docs to reference Python 3.10 #### Templates: * Updated __init__.py.j2 templates in gapic/ads-templates to require Python 3.10+ (updating sys.version_info checks and error messages). * Removed outdated comments regarding Python 3.9 and below features (like module-level __getattr__) to avoid confusion, as the baseline runtime is now higher than the version noted in the comments. * Updated mypy.ini.j2 to target Python 3.10. * Cleaned up dead code (e.g. commented-out Jinja snippets) in the templates. #### CI Configurations: * Removed Python 3.9 and below from the unit test matrix in ci/run_single_test.sh. * Updated comments regarding supported Python versions in ci/run_conditional_tests.sh. ### Reasoning Python 3.9 and below have reached End-of-Life (EOL) and are no longer supported. These changes ensure that our generator and the libraries it produces align with current support policies and reduce maintenance burden by removing dead code paths. > [!note] > because the config that runs this PR checks is not updated yet, it still wants to run 3.9 so we have a temp change to skip that nox session. Once this PR merges future PRs will no longer attempt to run 3.9 and we will follow-up with a small PR to strip out that last 3.9 reference. Fixes internal issue: http://b/482126936 🦕
1 parent 2bfa5d6 commit 6d68146

76 files changed

Lines changed: 219 additions & 563 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.generator/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ RUN unzip protoc-25.3-linux-x86_64.zip -d protoc
6666

6767
# Download/extract pandoc
6868
# Pandoc is required by gapic-generator-python for parsing documentation
69+
# version-scanner: ignore-next-line
6970
ENV PANDOC_VERSION=3.8.2
7071
RUN mkdir pandoc-binary
7172
RUN wget https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz

.generator/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def _run_post_processor(output: str, library_id: str, is_mono_repo: bool):
354354
# TODO(https://github.com/googleapis/google-cloud-python/issues/15538):
355355
# Investigate if a `target_version needs to be maintained
356356
# or can be eliminated.
357-
target_version = "py39"
357+
target_version = "py310"
358358
common_args = [
359359
f"--target-version={target_version}",
360360
"--line-length=88",

.generator/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ def test_run_individual_session_success(mocker, caplog, is_mono_repo):
741741
"cli.subprocess.run", return_value=MagicMock(returncode=0)
742742
)
743743

744-
test_session = "unit-3.9"
744+
test_session = "unit-3.10"
745745
test_library_id = "test-library"
746746
repo = "repo"
747747
_run_individual_session(test_session, test_library_id, repo, is_mono_repo)

.github/workflows/gapic-generator-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ env:
1818
SHOWCASE_VERSION: 0.35.0
1919
PROTOC_VERSION: 3.20.2
2020
LATEST_STABLE_PYTHON: 3.14
21-
ALL_PYTHON: "['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']"
21+
ALL_PYTHON: "['3.10', '3.11', '3.12', '3.13', '3.14']"
2222

2323
jobs:
2424
check_changes:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ repos:
2626
hooks:
2727
- id: black
2828
- repo: https://github.com/pycqa/flake8
29-
rev: 3.9.2
29+
rev: 3.9.2 # version-scanner: ignore
3030
hooks:
3131
- id: flake8

ci/run_conditional_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# `BUILD_TYPE` should be one of ["presubmit", "continuous"]
1818
# `TEST_TYPE` should be one of ["docs", "docfx", "prerelease", "unit"]
1919
# or match the name of the nox session that you want to run.
20-
# `PY_VERSION` should be one of ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
20+
# `PY_VERSION` should be one of ["3.10", "3.11", "3.12"]
2121

2222
# `TEST_TYPE` and `PY_VERSION` are required by the script `ci/run_single_test.sh`
2323

ci/run_single_test.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# This script requires the following environment variables to be set:
1818
# `TEST_TYPE` should be one of ["lint", "lint_setup_py", "docs", "docfx", "prerelease"]
19-
# `PY_VERSION` should be one of ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
19+
# `PY_VERSION` should be one of ["3.10", "3.11", "3.12", "3.13"]
2020

2121
# This script is called by the `ci/run_conditional_tests.sh` script.
2222
# A specific `nox` session will be run, depending on the value of
@@ -70,14 +70,6 @@ case ${TEST_TYPE} in
7070
;;
7171
unit)
7272
case ${PY_VERSION} in
73-
"3.7")
74-
nox -s unit-3.7
75-
retval=$?
76-
;;
77-
"3.8")
78-
nox -s unit-3.8
79-
retval=$?
80-
;;
8173
"3.9")
8274
nox -s unit-3.9
8375
retval=$?

packages/gapic-generator/docs/getting-started/_verifying.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Create a virtual environment for the library:
88

99
.. code-block:: shell
1010
11-
$ virtualenv ~/.local/client-lib --python=`which python3.7`
11+
$ virtualenv ~/.local/client-lib --python=`which python3.10`
1212
$ source ~/.local/client-lib/bin/activate
1313
1414
Next, install the library:

packages/gapic-generator/docs/getting-started/bazel.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ install it is simply downloading the binary and making it executable:
2929
Python and Dependencies
3030
~~~~~~~~~~~~~~~~~~~~~~~
3131
Bazel build is mostly hermetic, with a few exceptions for Python generator.
32-
Specifically it expects Python 3.7+ with the python dev packages to be installed.
32+
Specifically it expects Python 3.10+ with the python dev packages to be installed.
3333

3434
On Linux, to install those, simply run:
3535

packages/gapic-generator/docs/getting-started/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Getting Started
22
---------------
33

44
This code generator is implemented as a plugin to ``protoc``, the compiler
5-
for `protocol buffers`_, and will run in any environment that Python 3.7+ and
5+
for `protocol buffers`_, and will run in any environment that Python 3.10+ and
66
protocol buffers do.
77

88
It is recommended to install the tool locally and run it through ``protoc``.

0 commit comments

Comments
 (0)