Skip to content

Commit 3c0976a

Browse files
gcf-owl-bot[bot]partheaLinchin
authored
feat: Add support for Python 3.12 (#1736)
* chore(python): Add Python 3.12 Source-Link: googleapis/synthtool@af16e6d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5 * add trove classifier for python 3.12 * update kokoro configs * Add python 3.12 to noxfile.py * update georaphy sample requirements * update geography samples requirements * add testing constraint file for 3.12 * remove repr test --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]> Co-authored-by: Linchin <[email protected]>
1 parent 1f4ebb1 commit 3c0976a

20 files changed

+97
-24
lines changed

.github/.OwlBot.lock.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:caffe0a9277daeccc4d1de5c9b55ebba0901b57c2f713ec9c876b0d4ec064f61
17-
# created: 2023-11-08T19:46:45.022803742Z
16+
digest: sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5
17+
# created: 2023-11-23T18:17:28.105124211Z

.kokoro/presubmit/prerelease-deps-3.11.cfg .kokoro/presubmit/prerelease-deps-3.12.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Only run this nox session.
44
env_vars: {
55
key: "NOX_SESSION"
6-
value: "prerelease_deps-3.11"
6+
value: "prerelease_deps-3.12"
77
}

.kokoro/presubmit/snippets-3.11.cfg .kokoro/presubmit/snippets-3.12.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Only run this nox session.
44
env_vars: {
55
key: "NOX_SESSION"
6-
value: "snippets-3.11"
6+
value: "snippets-3.12"
77
}

.kokoro/presubmit/system-3.11.cfg .kokoro/presubmit/system-3.12.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Only run this nox session.
44
env_vars: {
55
key: "NOX_SESSION"
6-
value: "system-3.11"
6+
value: "system-3.12"
77
}

.kokoro/samples/python3.12/common.cfg

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Build logs will be here
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Specify which tests to run
11+
env_vars: {
12+
key: "RUN_TESTS_SESSION"
13+
value: "py-3.12"
14+
}
15+
16+
# Declare build specific Cloud project.
17+
env_vars: {
18+
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
19+
value: "python-docs-samples-tests-312"
20+
}
21+
22+
env_vars: {
23+
key: "TRAMPOLINE_BUILD_FILE"
24+
value: "github/python-bigquery/.kokoro/test-samples.sh"
25+
}
26+
27+
# Configure the docker image for kokoro-trampoline.
28+
env_vars: {
29+
key: "TRAMPOLINE_IMAGE"
30+
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
31+
}
32+
33+
# Download secrets for samples
34+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
35+
36+
# Download trampoline resources.
37+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
38+
39+
# Use the trampoline script to run in docker.
40+
build_file: "python-bigquery/.kokoro/trampoline_v2.sh"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "True"
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "True"
6+
}
7+
8+
env_vars: {
9+
key: "TRAMPOLINE_BUILD_FILE"
10+
value: "github/python-bigquery/.kokoro/test-samples-against-head.sh"
11+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "False"
6+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "True"
6+
}

CONTRIBUTING.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In order to add a feature:
2222
documentation.
2323

2424
- The feature must work fully on the following CPython versions:
25-
3.7, 3.8, 3.9, 3.10 and 3.11 on both UNIX and Windows.
25+
3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 on both UNIX and Windows.
2626

2727
- The feature must not add unnecessary dependencies (where
2828
"unnecessary" is of course subjective, but new dependencies should
@@ -72,7 +72,7 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
7272

7373
- To run a single unit test::
7474

75-
$ nox -s unit-3.11 -- -k <name of test>
75+
$ nox -s unit-3.12 -- -k <name of test>
7676

7777

7878
.. note::
@@ -226,12 +226,14 @@ We support:
226226
- `Python 3.9`_
227227
- `Python 3.10`_
228228
- `Python 3.11`_
229+
- `Python 3.12`_
229230

230231
.. _Python 3.7: https://docs.python.org/3.7/
231232
.. _Python 3.8: https://docs.python.org/3.8/
232233
.. _Python 3.9: https://docs.python.org/3.9/
233234
.. _Python 3.10: https://docs.python.org/3.10/
234235
.. _Python 3.11: https://docs.python.org/3.11/
236+
.. _Python 3.12: https://docs.python.org/3.12/
235237

236238

237239
Supported versions can be found in our ``noxfile.py`` `config`_.

noxfile.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
)
3838

3939
DEFAULT_PYTHON_VERSION = "3.8"
40-
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.11"]
41-
UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
40+
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.11", "3.12"]
41+
UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
4242
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
4343

4444
# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
@@ -81,7 +81,7 @@ def default(session, install_extras=True):
8181
constraints_path,
8282
)
8383

84-
if install_extras and session.python == "3.11":
84+
if install_extras and session.python in ["3.11", "3.12"]:
8585
install_target = ".[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
8686
elif install_extras:
8787
install_target = ".[all]"
@@ -187,7 +187,7 @@ def system(session):
187187
# Data Catalog needed for the column ACL test with a real Policy Tag.
188188
session.install("google-cloud-datacatalog", "-c", constraints_path)
189189

190-
if session.python == "3.11":
190+
if session.python in ["3.11", "3.12"]:
191191
extras = "[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
192192
else:
193193
extras = "[all]"
@@ -251,7 +251,7 @@ def snippets(session):
251251
session.install("google-cloud-storage", "-c", constraints_path)
252252
session.install("grpcio", "-c", constraints_path)
253253

254-
if session.python == "3.11":
254+
if session.python in ["3.11", "3.12"]:
255255
extras = "[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
256256
else:
257257
extras = "[all]"

samples/desktopapp/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
8989

9090
# DO NOT EDIT - automatically generated.
9191
# All versions used to test samples.
92-
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
92+
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
9393

9494
# Any default versions that should be ignored.
9595
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]

samples/geography/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
8989

9090
# DO NOT EDIT - automatically generated.
9191
# All versions used to test samples.
92-
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
92+
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
9393

9494
# Any default versions that should be ignored.
9595
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]

samples/geography/requirements.txt

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ click-plugins==1.1.1
77
cligj==0.7.2
88
dataclasses==0.8; python_version < '3.7'
99
db-dtypes==1.1.1
10-
Fiona==1.9.4.post1
11-
geojson==3.0.1
10+
Fiona==1.9.5
11+
geojson==3.1.0
1212
geopandas===0.10.2; python_version == '3.7'
13-
geopandas==0.13.2; python_version >= '3.8'
13+
geopandas==0.13.2; python_version == '3.8'
14+
geopandas==0.14.1; python_version >= '3.9'
1415
google-api-core==2.11.1
1516
google-auth==2.22.0
1617
google-cloud-bigquery==3.11.4
@@ -19,9 +20,10 @@ google-cloud-core==2.3.3
1920
google-crc32c==1.5.0
2021
google-resumable-media==2.5.0
2122
googleapis-common-protos==1.60.0
22-
grpcio==1.57.0
23+
grpcio==1.59.0
2324
idna==3.4
24-
libcst==1.0.1
25+
libcst==1.0.1; python_version == '3.7'
26+
libcst==1.1.0; python_version >= '3.8'
2527
munch==4.0.0
2628
mypy-extensions==1.0.0
2729
packaging==23.1
@@ -39,7 +41,7 @@ pytz==2023.3
3941
PyYAML==6.0.1
4042
requests==2.31.0
4143
rsa==4.9
42-
Shapely==2.0.1
44+
Shapely==2.0.2
4345
six==1.16.0
4446
typing-extensions==4.7.1
4547
typing-inspect==0.9.0

samples/magics/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
8989

9090
# DO NOT EDIT - automatically generated.
9191
# All versions used to test samples.
92-
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
92+
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
9393

9494
# Any default versions that should be ignored.
9595
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]

samples/notebooks/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
8989

9090
# DO NOT EDIT - automatically generated.
9191
# All versions used to test samples.
92-
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
92+
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
9393

9494
# Any default versions that should be ignored.
9595
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]

samples/snippets/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
8989

9090
# DO NOT EDIT - automatically generated.
9191
# All versions used to test samples.
92-
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
92+
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
9393

9494
# Any default versions that should be ignored.
9595
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
"Programming Language :: Python :: 3.9",
134134
"Programming Language :: Python :: 3.10",
135135
"Programming Language :: Python :: 3.11",
136+
"Programming Language :: Python :: 3.12",
136137
"Operating System :: OS Independent",
137138
"Topic :: Internet",
138139
],

testing/constraints-3.12.txt

Whitespace-only changes.

tests/unit/test_query.py

-1
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,6 @@ def test___repr__(self):
12811281
field1 = self._make_one("test", _make_subparam("field1", "STRING", "hello"))
12821282
got = repr(field1)
12831283
self.assertIn("StructQueryParameter", got)
1284-
self.assertIn("'field1', 'STRING'", got)
12851284
self.assertIn("'field1': 'hello'", got)
12861285

12871286

0 commit comments

Comments
 (0)