Skip to content

Commit 660b8ea

Browse files
feat: Add support for Python 3.12 (#1025)
* 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 python 3.12 to setup.py and owlbot.py * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix incorrect usage of assert_called_once() * update required checks --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 0432420 commit 660b8ea

File tree

14 files changed

+95
-14
lines changed

14 files changed

+95
-14
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

.github/sync-repo-settings.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,16 @@ branchProtectionRules:
1515
- 'Samples - Python 3.8'
1616
- 'Samples - Python 3.9'
1717
- 'Samples - Python 3.10'
18+
- 'Samples - Python 3.11'
19+
- 'Samples - Python 3.12'
1820
- 'OwlBot Post Processor'
21+
- 'docs'
22+
- 'docfx'
23+
- 'lint'
24+
- 'unit (3.7)'
25+
- 'unit (3.8)'
26+
- 'unit (3.9)'
27+
- 'unit (3.10)'
28+
- 'unit (3.11)'
29+
- 'unit (3.12)'
30+
- 'cover'

.github/workflows/unittest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
11+
python: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v3

.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-pubsub/.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-pubsub/.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-pubsub/.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

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636

3737
DEFAULT_PYTHON_VERSION = "3.8"
3838

39-
UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.7", "3.8", "3.9", "3.10", "3.11"]
39+
UNIT_TEST_PYTHON_VERSIONS: List[str] = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
4040
UNIT_TEST_STANDARD_DEPENDENCIES = [
41-
"mock==5.0.0",
41+
"mock",
4242
"asyncmock",
4343
"pytest",
4444
"pytest-cov",
@@ -52,7 +52,7 @@
5252

5353
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.10"]
5454
SYSTEM_TEST_STANDARD_DEPENDENCIES: List[str] = [
55-
"mock==5.0.0",
55+
"mock",
5656
"pytest",
5757
"google-cloud-testutils",
5858
]

owlbot.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@
336336
samples=True,
337337
cov_level=100,
338338
versions=gcp.common.detect_versions(path="./google", default_first=True),
339-
unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11"],
339+
unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"],
340340
system_test_python_versions=["3.10"],
341341
system_test_external_dependencies=["psutil","flaky"],
342342
)
@@ -353,9 +353,6 @@
353353
s.replace(
354354
"noxfile.py", r'"blacken",', '\g<0>\n "mypy",',
355355
)
356-
s.replace(
357-
"noxfile.py", r'"mock"', '"mock==5.0.0"',
358-
)
359356
s.replace(
360357
"noxfile.py",
361358
r"nox\.options\.error_on_missing_interpreters = True",

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
@@ -80,6 +80,7 @@
8080
"Programming Language :: Python :: 3.9",
8181
"Programming Language :: Python :: 3.10",
8282
"Programming Language :: Python :: 3.11",
83+
"Programming Language :: Python :: 3.12",
8384
"Operating System :: OS Independent",
8485
"Topic :: Internet",
8586
],

tests/unit/pubsub_v1/publisher/test_publisher_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def test_resume_publish(creds):
636636
client._set_sequencer(topic=topic, sequencer=sequencer, ordering_key=ordering_key)
637637

638638
client.resume_publish(topic, ordering_key)
639-
assert sequencer.unpause.called_once()
639+
sequencer.unpause.assert_called_once()
640640

641641

642642
def test_resume_publish_no_sequencer_found(creds):

0 commit comments

Comments
 (0)