Skip to content

Commit

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

Source-Link: googleapis/synthtool@af16e6d
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5

* add trove classifier for python 3.12

* update kokoro configs

* Add python 3.12 to noxfile.py

* update georaphy sample requirements

* update geography samples requirements

* add testing constraint file for 3.12

* remove repr test

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Linchin <lingqing.gan@gmail.com>
  • Loading branch information
4 people committed Dec 1, 2023
1 parent 1f4ebb1 commit 3c0976a
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/.OwlBot.lock.yaml
Expand Up @@ -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
Expand Up @@ -3,5 +3,5 @@
# Only run this nox session.
env_vars: {
key: "NOX_SESSION"
value: "prerelease_deps-3.11"
value: "prerelease_deps-3.12"
}
Expand Up @@ -3,5 +3,5 @@
# Only run this nox session.
env_vars: {
key: "NOX_SESSION"
value: "snippets-3.11"
value: "snippets-3.12"
}
Expand Up @@ -3,5 +3,5 @@
# Only run this nox session.
env_vars: {
key: "NOX_SESSION"
value: "system-3.11"
value: "system-3.12"
}
40 changes: 40 additions & 0 deletions .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-bigquery/.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-bigquery/.kokoro/trampoline_v2.sh"
6 changes: 6 additions & 0 deletions .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"
}
11 changes: 11 additions & 0 deletions .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-bigquery/.kokoro/test-samples-against-head.sh"
}
6 changes: 6 additions & 0 deletions .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"
}
6 changes: 6 additions & 0 deletions .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"
}
6 changes: 4 additions & 2 deletions CONTRIBUTING.rst
Expand Up @@ -22,7 +22,7 @@ In order to add a feature:
documentation.

- The feature must work fully on the following CPython versions:
3.7, 3.8, 3.9, 3.10 and 3.11 on both UNIX and Windows.
3.7, 3.8, 3.9, 3.10, 3.11 and 3.12 on both UNIX and Windows.

- The feature must not add unnecessary dependencies (where
"unnecessary" is of course subjective, but new dependencies should
Expand Down Expand Up @@ -72,7 +72,7 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.

- To run a single unit test::

$ nox -s unit-3.11 -- -k <name of test>
$ nox -s unit-3.12 -- -k <name of test>


.. note::
Expand Down Expand Up @@ -226,12 +226,14 @@ We support:
- `Python 3.9`_
- `Python 3.10`_
- `Python 3.11`_
- `Python 3.12`_

.. _Python 3.7: https://docs.python.org/3.7/
.. _Python 3.8: https://docs.python.org/3.8/
.. _Python 3.9: https://docs.python.org/3.9/
.. _Python 3.10: https://docs.python.org/3.10/
.. _Python 3.11: https://docs.python.org/3.11/
.. _Python 3.12: https://docs.python.org/3.12/


Supported versions can be found in our ``noxfile.py`` `config`_.
Expand Down
10 changes: 5 additions & 5 deletions noxfile.py
Expand Up @@ -37,8 +37,8 @@
)

DEFAULT_PYTHON_VERSION = "3.8"
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.11"]
UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.11", "3.12"]
UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()

# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
Expand Down Expand Up @@ -81,7 +81,7 @@ def default(session, install_extras=True):
constraints_path,
)

if install_extras and session.python == "3.11":
if install_extras and session.python in ["3.11", "3.12"]:
install_target = ".[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
elif install_extras:
install_target = ".[all]"
Expand Down Expand Up @@ -187,7 +187,7 @@ def system(session):
# Data Catalog needed for the column ACL test with a real Policy Tag.
session.install("google-cloud-datacatalog", "-c", constraints_path)

if session.python == "3.11":
if session.python in ["3.11", "3.12"]:
extras = "[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
else:
extras = "[all]"
Expand Down Expand Up @@ -251,7 +251,7 @@ def snippets(session):
session.install("google-cloud-storage", "-c", constraints_path)
session.install("grpcio", "-c", constraints_path)

if session.python == "3.11":
if session.python in ["3.11", "3.12"]:
extras = "[bqstorage,ipywidgets,pandas,tqdm,opentelemetry]"
else:
extras = "[all]"
Expand Down
2 changes: 1 addition & 1 deletion samples/desktopapp/noxfile.py
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
2 changes: 1 addition & 1 deletion samples/geography/noxfile.py
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
14 changes: 8 additions & 6 deletions samples/geography/requirements.txt
Expand Up @@ -7,10 +7,11 @@ click-plugins==1.1.1
cligj==0.7.2
dataclasses==0.8; python_version < '3.7'
db-dtypes==1.1.1
Fiona==1.9.4.post1
geojson==3.0.1
Fiona==1.9.5
geojson==3.1.0
geopandas===0.10.2; python_version == '3.7'
geopandas==0.13.2; python_version >= '3.8'
geopandas==0.13.2; python_version == '3.8'
geopandas==0.14.1; python_version >= '3.9'
google-api-core==2.11.1
google-auth==2.22.0
google-cloud-bigquery==3.11.4
Expand All @@ -19,9 +20,10 @@ google-cloud-core==2.3.3
google-crc32c==1.5.0
google-resumable-media==2.5.0
googleapis-common-protos==1.60.0
grpcio==1.57.0
grpcio==1.59.0
idna==3.4
libcst==1.0.1
libcst==1.0.1; python_version == '3.7'
libcst==1.1.0; python_version >= '3.8'
munch==4.0.0
mypy-extensions==1.0.0
packaging==23.1
Expand All @@ -39,7 +41,7 @@ pytz==2023.3
PyYAML==6.0.1
requests==2.31.0
rsa==4.9
Shapely==2.0.1
Shapely==2.0.2
six==1.16.0
typing-extensions==4.7.1
typing-inspect==0.9.0
Expand Down
2 changes: 1 addition & 1 deletion samples/magics/noxfile.py
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
2 changes: 1 addition & 1 deletion samples/notebooks/noxfile.py
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
2 changes: 1 addition & 1 deletion samples/snippets/noxfile.py
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
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -133,6 +133,7 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
"Topic :: Internet",
],
Expand Down
Empty file added testing/constraints-3.12.txt
Empty file.
1 change: 0 additions & 1 deletion tests/unit/test_query.py
Expand Up @@ -1281,7 +1281,6 @@ def test___repr__(self):
field1 = self._make_one("test", _make_subparam("field1", "STRING", "hello"))
got = repr(field1)
self.assertIn("StructQueryParameter", got)
self.assertIn("'field1', 'STRING'", got)
self.assertIn("'field1': 'hello'", got)


Expand Down

0 comments on commit 3c0976a

Please sign in to comment.