From fbbf174066061d95cb09bf269e2da447c288bd6b Mon Sep 17 00:00:00 2001
From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com>
Date: Thu, 30 Nov 2023 16:04:07 -0500
Subject: [PATCH] feat: Add support for Python 3.12 (#192)

* chore(python): Add Python 3.12

Source-Link: https://github.com/googleapis/synthtool/commit/af16e6d4672cc7b400f144de2fc3068b54ff47d2
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5

* Add python 3.12 to setup.py, noxfile.py and constraints

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
---
 .../.github/.OwlBot.lock.yaml                 |  4 +-
 .../.kokoro/samples/python3.12/common.cfg     | 40 +++++++++++++++++++
 .../.kokoro/samples/python3.12/continuous.cfg |  6 +++
 .../samples/python3.12/periodic-head.cfg      | 11 +++++
 .../.kokoro/samples/python3.12/periodic.cfg   |  6 +++
 .../.kokoro/samples/python3.12/presubmit.cfg  |  6 +++
 packages/googleapis-common-protos/noxfile.py  |  4 +-
 packages/googleapis-common-protos/setup.py    |  1 +
 .../testing/constraints-3.12.txt              |  0
 9 files changed, 74 insertions(+), 4 deletions(-)
 create mode 100644 packages/googleapis-common-protos/.kokoro/samples/python3.12/common.cfg
 create mode 100644 packages/googleapis-common-protos/.kokoro/samples/python3.12/continuous.cfg
 create mode 100644 packages/googleapis-common-protos/.kokoro/samples/python3.12/periodic-head.cfg
 create mode 100644 packages/googleapis-common-protos/.kokoro/samples/python3.12/periodic.cfg
 create mode 100644 packages/googleapis-common-protos/.kokoro/samples/python3.12/presubmit.cfg
 create mode 100644 packages/googleapis-common-protos/testing/constraints-3.12.txt

diff --git a/packages/googleapis-common-protos/.github/.OwlBot.lock.yaml b/packages/googleapis-common-protos/.github/.OwlBot.lock.yaml
index 453b540c1e58..eb4d9f794dc1 100644
--- a/packages/googleapis-common-protos/.github/.OwlBot.lock.yaml
+++ b/packages/googleapis-common-protos/.github/.OwlBot.lock.yaml
@@ -13,5 +13,5 @@
 # limitations under the License.
 docker:
   image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
-  digest: sha256:caffe0a9277daeccc4d1de5c9b55ebba0901b57c2f713ec9c876b0d4ec064f61
-# created: 2023-11-08T19:46:45.022803742Z
+  digest: sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5
+# created: 2023-11-23T18:17:28.105124211Z
diff --git a/packages/googleapis-common-protos/.kokoro/samples/python3.12/common.cfg b/packages/googleapis-common-protos/.kokoro/samples/python3.12/common.cfg
new file mode 100644
index 000000000000..041b59471c61
--- /dev/null
+++ b/packages/googleapis-common-protos/.kokoro/samples/python3.12/common.cfg
@@ -0,0 +1,40 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+  define_artifacts {
+    regex: "**/*sponge_log.xml"
+  }
+}
+
+# Specify which tests to run
+env_vars: {
+    key: "RUN_TESTS_SESSION"
+    value: "py-3.12"
+}
+
+# Declare build specific Cloud project.
+env_vars: {
+    key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+    value: "python-docs-samples-tests-312"
+}
+
+env_vars: {
+    key: "TRAMPOLINE_BUILD_FILE"
+    value: "github/python-api-common-protos/.kokoro/test-samples.sh"
+}
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+    key: "TRAMPOLINE_IMAGE"
+    value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
+}
+
+# Download secrets for samples
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "python-api-common-protos/.kokoro/trampoline_v2.sh"
\ No newline at end of file
diff --git a/packages/googleapis-common-protos/.kokoro/samples/python3.12/continuous.cfg b/packages/googleapis-common-protos/.kokoro/samples/python3.12/continuous.cfg
new file mode 100644
index 000000000000..a1c8d9759c88
--- /dev/null
+++ b/packages/googleapis-common-protos/.kokoro/samples/python3.12/continuous.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+    key: "INSTALL_LIBRARY_FROM_SOURCE"
+    value: "True"
+}
\ No newline at end of file
diff --git a/packages/googleapis-common-protos/.kokoro/samples/python3.12/periodic-head.cfg b/packages/googleapis-common-protos/.kokoro/samples/python3.12/periodic-head.cfg
new file mode 100644
index 000000000000..4b0b0711955f
--- /dev/null
+++ b/packages/googleapis-common-protos/.kokoro/samples/python3.12/periodic-head.cfg
@@ -0,0 +1,11 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+    key: "INSTALL_LIBRARY_FROM_SOURCE"
+    value: "True"
+}
+
+env_vars: {
+    key: "TRAMPOLINE_BUILD_FILE"
+    value: "github/python-api-common-protos/.kokoro/test-samples-against-head.sh"
+}
diff --git a/packages/googleapis-common-protos/.kokoro/samples/python3.12/periodic.cfg b/packages/googleapis-common-protos/.kokoro/samples/python3.12/periodic.cfg
new file mode 100644
index 000000000000..71cd1e597e38
--- /dev/null
+++ b/packages/googleapis-common-protos/.kokoro/samples/python3.12/periodic.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+    key: "INSTALL_LIBRARY_FROM_SOURCE"
+    value: "False"
+}
diff --git a/packages/googleapis-common-protos/.kokoro/samples/python3.12/presubmit.cfg b/packages/googleapis-common-protos/.kokoro/samples/python3.12/presubmit.cfg
new file mode 100644
index 000000000000..a1c8d9759c88
--- /dev/null
+++ b/packages/googleapis-common-protos/.kokoro/samples/python3.12/presubmit.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+    key: "INSTALL_LIBRARY_FROM_SOURCE"
+    value: "True"
+}
\ No newline at end of file
diff --git a/packages/googleapis-common-protos/noxfile.py b/packages/googleapis-common-protos/noxfile.py
index 8939614e3bc2..a11c62685f9f 100644
--- a/packages/googleapis-common-protos/noxfile.py
+++ b/packages/googleapis-common-protos/noxfile.py
@@ -122,7 +122,7 @@ def system(session):
         session.run("py.test", "--verbose", system_test_folder_path, *session.posargs)
 
 
-@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
+@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"])
 @nox.parametrize(
     "library",
     [
@@ -169,7 +169,7 @@ def test(session, library):
             session.install("flaky")
         system(session)
 
-@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
+@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"])
 def tests_local(session):
     """Run tests in this local repo."""
     # Install all test dependencies, then install this package in-place.
diff --git a/packages/googleapis-common-protos/setup.py b/packages/googleapis-common-protos/setup.py
index 596466ccdb31..9171fb93822b 100644
--- a/packages/googleapis-common-protos/setup.py
+++ b/packages/googleapis-common-protos/setup.py
@@ -53,6 +53,7 @@
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
         "Programming Language :: Python :: 3.11",
+        "Programming Language :: Python :: 3.12",
         "Programming Language :: Python :: Implementation :: CPython",
     ],
     description=description,
diff --git a/packages/googleapis-common-protos/testing/constraints-3.12.txt b/packages/googleapis-common-protos/testing/constraints-3.12.txt
new file mode 100644
index 000000000000..e69de29bb2d1