Skip to content

Commit af16e6d

Browse files
authored
chore(python): Add Python 3.12 (#1903)
* feat(python): Adding Python3.12 support * Reformatting
1 parent 74ed3eb commit af16e6d

File tree

8 files changed

+105
-4
lines changed

8 files changed

+105
-4
lines changed

synthtool/gcp/common.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,14 @@ def py_library(self, **kwargs) -> Path:
265265
if "default_python_version" not in kwargs:
266266
kwargs["default_python_version"] = "3.8"
267267
if "unit_test_python_versions" not in kwargs:
268-
kwargs["unit_test_python_versions"] = ["3.7", "3.8", "3.9", "3.10", "3.11"]
268+
kwargs["unit_test_python_versions"] = [
269+
"3.7",
270+
"3.8",
271+
"3.9",
272+
"3.10",
273+
"3.11",
274+
"3.12",
275+
]
269276

270277
if "system_test_python_versions" not in kwargs:
271278
kwargs["system_test_python_versions"] = ["3.8"]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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/{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/test-samples.sh"
25+
}
26+
{% if custom_samples_dockerfile %}
27+
env_vars: {
28+
key: "TRAMPOLINE_IMAGE"
29+
value: "gcr.io/cloud-devrel-kokoro-resources/{{ metadata['repo']['repo'].split('/')[1] }}-samples-docker"
30+
}
31+
32+
# Configure the docker image for kokoro-trampoline.
33+
env_vars: {
34+
key: "TRAMPOLINE_DOCKERFILE"
35+
value: ".kokoro/docker/samples/Dockerfile"
36+
}
37+
{% else %}
38+
# Configure the docker image for kokoro-trampoline.
39+
env_vars: {
40+
key: "TRAMPOLINE_IMAGE"
41+
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
42+
}
43+
{% endif %}
44+
# Download secrets for samples
45+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
46+
47+
# Download trampoline resources.
48+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
49+
50+
# Use the trampoline script to run in docker.
51+
build_file: "{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/trampoline_v2.sh"
Lines changed: 6 additions & 0 deletions
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+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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/{{ metadata['repo']['repo'].split('/')[1] }}/.kokoro/test-samples-against-head.sh"
11+
}
12+
{% if custom_samples_dockerfile %}
13+
# Upload the docker image after successful builds.
14+
env_vars: {
15+
key: "TRAMPOLINE_IMAGE_UPLOAD"
16+
value: "true"
17+
}
18+
{% endif %}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
env_vars: {
4+
key: "INSTALL_LIBRARY_FROM_SOURCE"
5+
value: "False"
6+
}
7+
{% if custom_samples_dockerfile %}
8+
# Upload the docker image after successful builds.
9+
env_vars: {
10+
key: "TRAMPOLINE_IMAGE_UPLOAD"
11+
value: "true"
12+
}
13+
{% endif %}
Lines changed: 6 additions & 0 deletions
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+
}

synthtool/gcp/templates/python_samples/noxfile.py.j2

Lines changed: 1 addition & 1 deletion
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"]

synthtool/languages/python_mono_repo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ def owlbot_main(package_dir: str) -> None:
226226
relative_dir=f"packages/{package_name}",
227227
microgenerator=True,
228228
default_python_version="3.10",
229-
unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11"],
230-
system_test_python_versions=["3.8", "3.9", "3.10", "3.11"],
229+
unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"],
230+
system_test_python_versions=["3.8", "3.9", "3.10", "3.11", "3.12"],
231231
cov_level=100,
232232
versions=gcp.common.detect_versions(
233233
path=f"{package_dir}/google"

0 commit comments

Comments
 (0)