Skip to content

Commit

Permalink
chore(python): Add Python 3.12 (#1903)
Browse files Browse the repository at this point in the history
* feat(python): Adding Python3.12 support

* Reformatting
  • Loading branch information
m-strzelczyk authored Nov 23, 2023
1 parent 74ed3eb commit af16e6d
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 4 deletions.
9 changes: 8 additions & 1 deletion synthtool/gcp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,14 @@ def py_library(self, **kwargs) -> Path:
if "default_python_version" not in kwargs:
kwargs["default_python_version"] = "3.8"
if "unit_test_python_versions" not in kwargs:
kwargs["unit_test_python_versions"] = ["3.7", "3.8", "3.9", "3.10", "3.11"]
kwargs["unit_test_python_versions"] = [
"3.7",
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
]

if "system_test_python_versions" not in kwargs:
kwargs["system_test_python_versions"] = ["3.8"]
Expand Down
Original file line number Diff line number Diff line change
@@ -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.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/{{ 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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
Original file line number Diff line number Diff line change
@@ -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 %}
Original file line number Diff line number Diff line change
@@ -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 %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
2 changes: 1 addition & 1 deletion synthtool/gcp/templates/python_samples/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]

# Any default versions that should be ignored.
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
Expand Down
4 changes: 2 additions & 2 deletions synthtool/languages/python_mono_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,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"],
system_test_python_versions=["3.8", "3.9", "3.10", "3.11"],
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"],
cov_level=100,
versions=gcp.common.detect_versions(
path=f"{package_dir}/google"
Expand Down

0 comments on commit af16e6d

Please sign in to comment.