From ca0ef0441a8ba5a62ad606022b962bdd18290d6a Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 15 Oct 2024 14:35:36 +0000 Subject: [PATCH 1/3] feat: Add support for Python 3.13 --- synthtool/gcp/common.py | 1 + .../.kokoro/samples/python3.13/common.cfg | 51 +++++++++++++++++++ .../.kokoro/samples/python3.13/continuous.cfg | 6 +++ .../samples/python3.13/periodic-head.cfg | 18 +++++++ .../.kokoro/samples/python3.13/periodic.cfg | 13 +++++ .../.kokoro/samples/python3.13/presubmit.cfg | 6 +++ .../templates/python_library/noxfile.py.j2 | 4 +- .../python_mono_repo_library/noxfile.py.j2 | 4 +- .../templates/python_samples/noxfile.py.j2 | 2 +- synthtool/languages/python_mono_repo.py | 4 +- 10 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/common.cfg create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/continuous.cfg create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/periodic-head.cfg create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/periodic.cfg create mode 100644 synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/presubmit.cfg diff --git a/synthtool/gcp/common.py b/synthtool/gcp/common.py index c4519aa2f..02123c256 100644 --- a/synthtool/gcp/common.py +++ b/synthtool/gcp/common.py @@ -274,6 +274,7 @@ def py_library(self, **kwargs) -> Path: "3.10", "3.11", "3.12", + "3.13", ] if "system_test_python_versions" not in kwargs: diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/common.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/common.cfg new file mode 100644 index 000000000..5d2a01cc6 --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/common.cfg @@ -0,0 +1,51 @@ +# 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.13" +} + +# Declare build specific Cloud project. +env_vars: { + key: "BUILD_SPECIFIC_GCLOUD_PROJECT" + value: "python-docs-samples-tests-313" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/test-samples.sh" +} +{% if custom_samples_dockerfile %} +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/{{ metadata['repo']['repo'].split('/')[1] }}-samples-docker" +} + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_DOCKERFILE" + value: ".kokoro/docker/samples/Dockerfile" +} +{% else %} +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker" +} +{% endif %} +# 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: "{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/trampoline_v2.sh" \ No newline at end of file diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/continuous.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/continuous.cfg new file mode 100644 index 000000000..a1c8d9759 --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/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/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/periodic-head.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/periodic-head.cfg new file mode 100644 index 000000000..da31f1cdf --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/periodic-head.cfg @@ -0,0 +1,18 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/test-samples-against-head.sh" +} +{% if custom_samples_dockerfile %} +# Upload the docker image after successful builds. +env_vars: { + key: "TRAMPOLINE_IMAGE_UPLOAD" + value: "true" +} +{% endif %} \ No newline at end of file diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/periodic.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/periodic.cfg new file mode 100644 index 000000000..f7ea9d9b9 --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/periodic.cfg @@ -0,0 +1,13 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "False" +} +{% if custom_samples_dockerfile %} +# Upload the docker image after successful builds. +env_vars: { + key: "TRAMPOLINE_IMAGE_UPLOAD" + value: "true" +} +{% endif %} \ No newline at end of file diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/presubmit.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/presubmit.cfg new file mode 100644 index 000000000..a1c8d9759 --- /dev/null +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/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/synthtool/gcp/templates/python_library/noxfile.py.j2 b/synthtool/gcp/templates/python_library/noxfile.py.j2 index 508f071ef..faebcb122 100644 --- a/synthtool/gcp/templates/python_library/noxfile.py.j2 +++ b/synthtool/gcp/templates/python_library/noxfile.py.j2 @@ -235,7 +235,7 @@ def install_unittest_dependencies(session, *constraints): def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): session.skip("cpp implementation is not supported in python 3.11+") constraints_path = str( @@ -444,7 +444,7 @@ def docfx(session): def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): session.skip("cpp implementation is not supported in python 3.11+") # Install all dependencies diff --git a/synthtool/gcp/templates/python_mono_repo_library/noxfile.py.j2 b/synthtool/gcp/templates/python_mono_repo_library/noxfile.py.j2 index 361f7cadc..faf989a2d 100644 --- a/synthtool/gcp/templates/python_mono_repo_library/noxfile.py.j2 +++ b/synthtool/gcp/templates/python_mono_repo_library/noxfile.py.j2 @@ -240,7 +240,7 @@ def install_unittest_dependencies(session, *constraints): def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): session.skip("cpp implementation is not supported in python 3.11+") constraints_path = str( @@ -453,7 +453,7 @@ def docfx(session): def prerelease_deps(session, protobuf_implementation): """Run all tests with prerelease versions of dependencies installed.""" - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"): + if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): session.skip("cpp implementation is not supported in python 3.11+") # Install all dependencies diff --git a/synthtool/gcp/templates/python_samples/noxfile.py.j2 b/synthtool/gcp/templates/python_samples/noxfile.py.j2 index 483b55901..a169b5b5b 100644 --- a/synthtool/gcp/templates/python_samples/noxfile.py.j2 +++ b/synthtool/gcp/templates/python_samples/noxfile.py.j2 @@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to test samples. -ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] +ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] diff --git a/synthtool/languages/python_mono_repo.py b/synthtool/languages/python_mono_repo.py index 0b03d7432..4d46891ce 100644 --- a/synthtool/languages/python_mono_repo.py +++ b/synthtool/languages/python_mono_repo.py @@ -235,8 +235,8 @@ def owlbot_main(package_dir: str) -> None: relative_dir=f"packages/{package_name}", microgenerator=True, default_python_version="3.10", - unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"], - system_test_python_versions=["3.8", "3.9", "3.10", "3.11", "3.12"], + unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"], + system_test_python_versions=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"], cov_level=100, versions=gcp.common.detect_versions( path=f"{package_dir}/google" From 9cc5b8673d59525eb54a6d6b6774608d4a4da290 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 15 Oct 2024 12:54:27 -0400 Subject: [PATCH 2/3] Update synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/common.cfg Co-authored-by: ohmayr --- .../python_library/.kokoro/samples/python3.13/common.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/common.cfg b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/common.cfg index 5d2a01cc6..5b7d14b97 100644 --- a/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/common.cfg +++ b/synthtool/gcp/templates/python_library/.kokoro/samples/python3.13/common.cfg @@ -48,4 +48,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" # Use the trampoline script to run in docker. -build_file: "{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/trampoline_v2.sh" \ No newline at end of file +build_file: "{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/trampoline_v2.sh" From d636042feda8806ec13514f75d5c23c48d7ee612 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 15 Oct 2024 16:56:55 +0000 Subject: [PATCH 3/3] lint --- synthtool/languages/python_mono_repo.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/synthtool/languages/python_mono_repo.py b/synthtool/languages/python_mono_repo.py index 4d46891ce..1ae72a611 100644 --- a/synthtool/languages/python_mono_repo.py +++ b/synthtool/languages/python_mono_repo.py @@ -235,7 +235,15 @@ def owlbot_main(package_dir: str) -> None: relative_dir=f"packages/{package_name}", microgenerator=True, default_python_version="3.10", - unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"], + unit_test_python_versions=[ + "3.7", + "3.8", + "3.9", + "3.10", + "3.11", + "3.12", + "3.13", + ], system_test_python_versions=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"], cov_level=100, versions=gcp.common.detect_versions(