Skip to content

Commit 11de939

Browse files
authored
tests: add Python 3.15 pre-release testing (#17517)
Towards b/525422520 Fixes #16215
1 parent 0258405 commit 11de939

20 files changed

Lines changed: 180 additions & 51 deletions

File tree

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

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ env:
1818
SHOWCASE_VERSION: 0.35.0
1919
PROTOC_VERSION: 3.20.2
2020
LATEST_STABLE_PYTHON: 3.14
21-
ALL_PYTHON: "['3.10', '3.11', '3.12', '3.13', '3.14']"
21+
PRERELEASE_PYTHON: 3.15
22+
ALL_PYTHON: "['3.10', '3.11', '3.12', '3.13', '3.14', '3.15']"
23+
TRIMMED_PYTHON: "['3.10', '3.14', '3.15']"
24+
# Workaround: Allows libcst to compile on Python 3.15+ while PyO3 catches up
25+
# Can be removed once libcst releases a version with native Python 3.15 wheels
26+
# Follow https://github.com/Instagram/LibCST/issues/1445 for updates.
27+
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
2228

2329
jobs:
2430
check_changes:
@@ -47,6 +53,8 @@ jobs:
4753
outputs:
4854
all_python: ${{ env.ALL_PYTHON }}
4955
latest_stable_python: ${{ env.LATEST_STABLE_PYTHON }}
56+
prerelease_python: ${{ env.PRERELEASE_PYTHON }}
57+
trimmed_python: $${{ env.TRIMMED_PYTHON }}
5058
steps:
5159
- run: echo "Initializing config for gapic-generator"
5260

@@ -65,6 +73,12 @@ jobs:
6573
uses: actions/setup-python@v6
6674
with:
6775
python-version: "${{ matrix.python }}"
76+
allow-prereleases: true
77+
# Caches compiled wheels locally to prevent building heavy libraries
78+
# such as grpcio, which we build from scratch on every run for Python 3.15+.
79+
# Follow https://github.com/grpc/grpc/issues/41010 for updates.
80+
cache: 'pip'
81+
cache-dependency-path: '**/requirements*.txt'
6882
- name: Install System Deps & Protoc
6983
run: |
7084
sudo apt-get update && sudo apt-get install -y curl pandoc unzip
@@ -132,10 +146,16 @@ jobs:
132146
runs-on: ubuntu-latest
133147
steps:
134148
- uses: actions/checkout@v6
135-
- name: Set up Python
149+
- name: Set up Python ${{ needs.python_config.outputs.prerelease_python }}
136150
uses: actions/setup-python@v6
137151
with:
138-
python-version: ${{ needs.python_config.outputs.latest_stable_python }}
152+
python-version: ${{ needs.python_config.outputs.prerelease_python }}
153+
allow-prereleases: true
154+
# Caches compiled wheels locally to prevent building heavy libraries
155+
# such as grpcio, which we build from scratch on every run for Python 3.15+.
156+
# Follow https://github.com/grpc/grpc/issues/41010 for updates.
157+
cache: 'pip'
158+
cache-dependency-path: '**/requirements*.txt'
139159
- name: Install System Deps
140160
run: sudo apt-get update && sudo apt-get install -y pandoc
141161
- name: Run Goldens (Prerelease)
@@ -150,15 +170,20 @@ jobs:
150170
needs: python_config
151171
strategy:
152172
matrix:
153-
python: ["3.10", "3.14"]
173+
python: ${{ fromJSON(needs.python_config.outputs.trimmed_python) }}
154174
runs-on: ubuntu-latest
155175
steps:
156176
- uses: actions/checkout@v6
157177
- name: Set up Python
158178
uses: actions/setup-python@v6
159179
with:
160180
python-version: ${{ matrix.python }}
161-
# This fixes the Pandoc error
181+
allow-prereleases: true
182+
# Caches compiled wheels locally to prevent building heavy libraries
183+
# such as grpcio, which we build from scratch on every run for Python 3.15+.
184+
# Follow https://github.com/grpc/grpc/issues/41010 for updates.
185+
cache: 'pip'
186+
cache-dependency-path: '**/requirements*.txt'
162187
- name: Install System Deps & Protoc
163188
run: |
164189
sudo apt-get update && sudo apt-get install -y curl pandoc unzip

packages/gapic-generator/gapic/templates/noxfile.py.j2

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ ALL_PYTHON = [
3030
"3.12",
3131
"3.13",
3232
"3.14",
33+
"3.15",
3334
]
3435

3536
DEFAULT_PYTHON_VERSION = "3.14"
3637

37-
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):
38-
# Switch this to Python 3.15 alpha1
39-
# https://peps.python.org/pep-0790/
40-
PREVIEW_PYTHON_VERSION = "3.14"
38+
PREVIEW_PYTHON_VERSION = "3.15"
4139

4240
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
4341

@@ -567,7 +565,7 @@ def prerelease_deps(session, protobuf_implementation):
567565
)
568566

569567

570-
@nox.session(python=DEFAULT_PYTHON_VERSION)
568+
@nox.session(python=PREVIEW_PYTHON_VERSION)
571569
@nox.parametrize(
572570
"protobuf_implementation",
573571
["python", "upb"],
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% from '_pypi_packages.j2' import pypi_packages %}
2+
# We use the constraints file for the latest Python version
3+
# (currently this file) to check that the latest
4+
# major versions of dependencies are supported in setup.py.
5+
# List all library dependencies and extras in this file.
6+
# Require the latest major version be installed for each dependency.
7+
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0",
8+
# Then this file should have google-cloud-foo>=1
9+
google-api-core>=2
10+
google-auth>=2
11+
grpcio>=1
12+
proto-plus>=1
13+
protobuf>=7
14+
{% for package_tuple, package_info in pypi_packages.items() %}
15+
{# Quick check to make sure `package_info.package_name` is not the package being generated so we don't circularly include this package in its own constraints file. #}
16+
{% if api.naming.warehouse_package_name != package_info.package_name %}
17+
{% if api.requires_package(package_tuple) %}
18+
{{ package_info.package_name }}>={{ (package_info.upper_bound.split(".")[0] | int) - 1 }}
19+
{% endif %}
20+
{% endif %}
21+
{% endfor %}

packages/gapic-generator/noxfile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@
5050
"3.12",
5151
"3.13",
5252
"3.14",
53+
"3.15",
5354
)
5455

55-
NEWEST_PYTHON = ALL_PYTHON[-1]
56+
NEWEST_PYTHON = ALL_PYTHON[-2]
5657

5758

5859
@nox.session(python=ALL_PYTHON)

packages/gapic-generator/tests/integration/goldens/asset/noxfile.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@
3737
"3.12",
3838
"3.13",
3939
"3.14",
40+
"3.15",
4041
]
4142

4243
DEFAULT_PYTHON_VERSION = "3.14"
4344

44-
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):
45-
# Switch this to Python 3.15 alpha1
46-
# https://peps.python.org/pep-0790/
47-
PREVIEW_PYTHON_VERSION = "3.14"
45+
PREVIEW_PYTHON_VERSION = "3.15"
4846

4947
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
5048

@@ -559,7 +557,7 @@ def prerelease_deps(session, protobuf_implementation):
559557
)
560558

561559

562-
@nox.session(python=DEFAULT_PYTHON_VERSION)
560+
@nox.session(python=PREVIEW_PYTHON_VERSION)
563561
@nox.parametrize(
564562
"protobuf_implementation",
565563
["python", "upb"],
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# We use the constraints file for the latest Python version
2+
# (currently this file) to check that the latest
3+
# major versions of dependencies are supported in setup.py.
4+
# List all library dependencies and extras in this file.
5+
# Require the latest major version be installed for each dependency.
6+
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0",
7+
# Then this file should have google-cloud-foo>=1
8+
google-api-core>=2
9+
google-auth>=2
10+
grpcio>=1
11+
proto-plus>=1
12+
protobuf>=7
13+
google-cloud-access-context-manager>=0
14+
google-cloud-os-config>=1
15+
grpc-google-iam-v1>=0

packages/gapic-generator/tests/integration/goldens/credentials/noxfile.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@
3737
"3.12",
3838
"3.13",
3939
"3.14",
40+
"3.15",
4041
]
4142

4243
DEFAULT_PYTHON_VERSION = "3.14"
4344

44-
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):
45-
# Switch this to Python 3.15 alpha1
46-
# https://peps.python.org/pep-0790/
47-
PREVIEW_PYTHON_VERSION = "3.14"
45+
PREVIEW_PYTHON_VERSION = "3.15"
4846

4947
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
5048

@@ -559,7 +557,7 @@ def prerelease_deps(session, protobuf_implementation):
559557
)
560558

561559

562-
@nox.session(python=DEFAULT_PYTHON_VERSION)
560+
@nox.session(python=PREVIEW_PYTHON_VERSION)
563561
@nox.parametrize(
564562
"protobuf_implementation",
565563
["python", "upb"],
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# We use the constraints file for the latest Python version
2+
# (currently this file) to check that the latest
3+
# major versions of dependencies are supported in setup.py.
4+
# List all library dependencies and extras in this file.
5+
# Require the latest major version be installed for each dependency.
6+
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0",
7+
# Then this file should have google-cloud-foo>=1
8+
google-api-core>=2
9+
google-auth>=2
10+
grpcio>=1
11+
proto-plus>=1
12+
protobuf>=7

packages/gapic-generator/tests/integration/goldens/eventarc/noxfile.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@
3737
"3.12",
3838
"3.13",
3939
"3.14",
40+
"3.15",
4041
]
4142

4243
DEFAULT_PYTHON_VERSION = "3.14"
4344

44-
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2450):
45-
# Switch this to Python 3.15 alpha1
46-
# https://peps.python.org/pep-0790/
47-
PREVIEW_PYTHON_VERSION = "3.14"
45+
PREVIEW_PYTHON_VERSION = "3.15"
4846

4947
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
5048

@@ -559,7 +557,7 @@ def prerelease_deps(session, protobuf_implementation):
559557
)
560558

561559

562-
@nox.session(python=DEFAULT_PYTHON_VERSION)
560+
@nox.session(python=PREVIEW_PYTHON_VERSION)
563561
@nox.parametrize(
564562
"protobuf_implementation",
565563
["python", "upb"],
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# We use the constraints file for the latest Python version
2+
# (currently this file) to check that the latest
3+
# major versions of dependencies are supported in setup.py.
4+
# List all library dependencies and extras in this file.
5+
# Require the latest major version be installed for each dependency.
6+
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0",
7+
# Then this file should have google-cloud-foo>=1
8+
google-api-core>=2
9+
google-auth>=2
10+
grpcio>=1
11+
proto-plus>=1
12+
protobuf>=7
13+
grpc-google-iam-v1>=0

0 commit comments

Comments
 (0)