Skip to content

Commit

Permalink
feat: Add support for Python 3.12 (#1421)
Browse files Browse the repository at this point in the history
* feat: Add support for Python 3.12

* Add samples lint session

* Add constraints file for python 3.12

* chore: Refresh system test creds.

* only run specified nox session for samples

---------

Co-authored-by: Carl Lundin <clundin@google.com>
  • Loading branch information
parthea and clundin25 committed Nov 29, 2023
1 parent 7ab0fce commit 307916c
Show file tree
Hide file tree
Showing 25 changed files with 214 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ branchProtectionRules:
- 'Samples - Python 3.8'
- 'Samples - Python 3.9'
- 'Samples - Python 3.10'
- 'Samples - Python 3.11'
- 'Samples - Python 3.12'
permissionRules:
- team: actools-python
permission: admin
Expand Down
4 changes: 2 additions & 2 deletions .kokoro/samples-test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ gcloud config set project ${PROJECT_ID}
# Decrypt system test secrets
./scripts/decrypt-secrets.sh

# Run system tests which use a different noxfile
python3 -m nox -f samples/cloud-client/snippets/noxfile.py
# Run samples tests which use a different noxfile
python3 -m nox -f samples/cloud-client/snippets/noxfile.py -s "$RUN_TESTS_SESSION"
7 changes: 7 additions & 0 deletions .kokoro/samples/lint/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ action {
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "lint"
}


# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

Expand Down
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.10/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ action {
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "unit-3.10"
}

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

Expand Down
37 changes: 37 additions & 0 deletions .kokoro/samples/python3.11/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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: "unit-3.11"
}

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Download resources for system tests (service account key, etc.)
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-auth-library-python"

# Use the trampoline script to run in docker.
build_file: "google-auth-library-python/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-auth-library-python/.kokoro/build.sh"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-auth-library-python/.kokoro/samples-test-setup.sh"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.11/continuous.cfg
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"
}
11 changes: 11 additions & 0 deletions .kokoro/samples/python3.11/periodic-head.cfg
Original file line number Diff line number Diff line change
@@ -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/google-auth-library-python/.kokoro/test-samples-against-head.sh"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.11/periodic.cfg
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: "False"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.11/presubmit.cfg
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"
}
37 changes: 37 additions & 0 deletions .kokoro/samples/python3.12/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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: "unit-3.12"
}

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Download resources for system tests (service account key, etc.)
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-auth-library-python"

# Use the trampoline script to run in docker.
build_file: "google-auth-library-python/.kokoro/trampoline.sh"

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-auth-library-python/.kokoro/build.sh"
}
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/google-auth-library-python/.kokoro/samples-test-setup.sh"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.12/continuous.cfg
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"
}
11 changes: 11 additions & 0 deletions .kokoro/samples/python3.12/periodic-head.cfg
Original file line number Diff line number Diff line change
@@ -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/google-auth-library-python/.kokoro/test-samples-against-head.sh"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.12/periodic.cfg
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: "False"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.12/presubmit.cfg
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"
}
7 changes: 7 additions & 0 deletions .kokoro/samples/python3.7/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ action {
}
}


# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "unit-3.7"
}

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

Expand Down
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.8/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ action {
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "unit-3.8"
}

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

Expand Down
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.9/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ action {
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "unit-3.9"
}

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A few notes on making changes to ``google-auth-library-python``.
using ``nox -s docgen``.

- The change must work fully on the following CPython versions:
3.7, 3.8, 3.9, 3.10 across macOS, Linux, and Windows.
3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 across macOS, Linux, and Windows.

- The codebase *must* have 100% test statement coverage after each commit.
You can test coverage via ``nox -e cover``.
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def mypy(session):
session.run("mypy", "-p", "google", "-p", "tests", "-p", "tests_async")


@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 unit(session):
constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def authenticate_implicit_with_adc(project_id="your-google-cloud-project-id"):
print(bucket.name)
print("Listed all storage buckets.")

# [END auth_cloud_implicit_adc]
# [END auth_cloud_implicit_adc]
45 changes: 41 additions & 4 deletions samples/cloud-client/snippets/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import pathlib
import shutil

import nox

Expand All @@ -33,7 +31,36 @@
"docs/conf.py",
]

@nox.session(python=["3.7", "3.8", "3.9", "3.10"])

# Error if a python version is missing
nox.options.error_on_missing_interpreters = True

#
# Style Checks
#


# Linting with flake8.
#
# We ignore the following rules:
# E203: whitespace before ‘:’
# E266: too many leading ‘#’ for block comment
# E501: line too long
# I202: Additional newline in a section of imports
#
# We also need to specify the rules which are ignored by default:
# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121']
FLAKE8_COMMON_ARGS = [
"--show-source",
"--builtin=gettext",
"--max-complexity=20",
"--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py",
"--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202",
"--max-line-length=88",
]


@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"])
def unit(session):
# constraints_path = str(
# CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
Expand All @@ -45,4 +72,14 @@ def unit(session):
f"--junitxml=unit_{session.python}_sponge_log.xml",
"snippets_test.py",
# "tests_async",
)
)


@nox.session
def lint(session: nox.sessions.Session) -> None:
session.install("flake8")

args = FLAKE8_COMMON_ARGS + [
".",
]
session.run("flake8", *args)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.
1 change: 0 additions & 1 deletion testing/constraints-2.7.txt

This file was deleted.

1 change: 1 addition & 0 deletions testing/constraints-3.12.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
urllib3>2.0.0

0 comments on commit 307916c

Please sign in to comment.