Skip to content

Commit df2976f

Browse files
gcf-owl-bot[bot]partheatswast
authored
feat: Add support for Python 3.12 (#231)
* 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 python 3.12 to noxfile and setup.py * update system test to use python 3.12 * add constraints file for python 3.12 * add python 3.12 to owlbot.py * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add python 3.12 as a required check * skip recursion test * avoid matplotlib error * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]> Co-authored-by: Tim Swast <[email protected]>
1 parent 2ad1e46 commit df2976f

File tree

10 files changed

+29
-11
lines changed

10 files changed

+29
-11
lines changed

.github/sync-repo-settings.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ branchProtectionRules:
1515
- 'unit (3.9)'
1616
- 'unit (3.10)'
1717
- 'unit (3.11)'
18+
- 'unit (3.12)'
1819
- 'cover'
1920
- 'Kokoro presubmit'
2021
permissionRules:

.github/workflows/unittest.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python: ['3.9', '3.10', '3.11']
11+
python: ['3.9', '3.10', '3.11', '3.12']
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v4

CONTRIBUTING.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In order to add a feature:
2222
documentation.
2323

2424
- The feature must work fully on the following CPython versions:
25-
3.9, 3.10 and 3.11 on both UNIX and Windows.
25+
3.9, 3.10, 3.11 and 3.12 on both UNIX and Windows.
2626

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

7373
- To run a single unit test::
7474

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

7777

7878
.. note::
@@ -143,12 +143,12 @@ Running System Tests
143143
$ nox -s system
144144

145145
# Run a single system test
146-
$ nox -s system-3.11 -- -k <name of test>
146+
$ nox -s system-3.12 -- -k <name of test>
147147

148148

149149
.. note::
150150

151-
System tests are only configured to run under Python 3.9 and 3.11.
151+
System tests are only configured to run under Python 3.9, 3.11 and 3.12.
152152
For expediency, we do not run them in older versions of Python 3.
153153

154154
This alone will not run the tests. You'll need to change some local
@@ -261,10 +261,12 @@ We support:
261261
- `Python 3.9`_
262262
- `Python 3.10`_
263263
- `Python 3.11`_
264+
- `Python 3.12`_
264265

265266
.. _Python 3.9: https://docs.python.org/3.9/
266267
.. _Python 3.10: https://docs.python.org/3.10/
267268
.. _Python 3.11: https://docs.python.org/3.11/
269+
.. _Python 3.12: https://docs.python.org/3.12/
268270

269271

270272
Supported versions can be found in our ``noxfile.py`` `config`_.

bigframes/operations/_matplotlib/core.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import abc
1616
import typing
1717

18-
import matplotlib.pyplot as plt
19-
2018
DEFAULT_SAMPLING_N = 1000
2119
DEFAULT_SAMPLING_STATE = 0
2220

@@ -27,6 +25,11 @@ def generate(self):
2725
pass
2826

2927
def draw(self) -> None:
28+
# This import can fail with "Matplotlib failed to acquire the
29+
# following lock file" so import here to reduce the chance of
30+
# our parallel test suite from triggering this.
31+
import matplotlib.pyplot as plt
32+
3033
plt.draw_if_interactive()
3134

3235
@property

bigframes/pandas/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,9 @@ def to_datetime(
706706

707707
# SQL Compilation uses recursive algorithms on deep trees
708708
# 10M tree depth should be sufficient to generate any sql that is under bigquery limit
709+
# Note: This limit does not have the desired effect on Python 3.12 in
710+
# which the applicable limit is now hard coded. See:
711+
# https://github.com/python/cpython/issues/112282
709712
sys.setrecursionlimit(max(10000000, sys.getrecursionlimit()))
710713
resource.setrlimit(
711714
resource.RLIMIT_STACK, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)

noxfile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
DEFAULT_PYTHON_VERSION = "3.10"
4141

42-
UNIT_TEST_PYTHON_VERSIONS = ["3.9", "3.10", "3.11"]
42+
UNIT_TEST_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12"]
4343
UNIT_TEST_STANDARD_DEPENDENCIES = [
4444
"mock",
4545
"asyncmock",
@@ -54,7 +54,7 @@
5454
UNIT_TEST_EXTRAS: List[str] = []
5555
UNIT_TEST_EXTRAS_BY_PYTHON: Dict[str, List[str]] = {}
5656

57-
SYSTEM_TEST_PYTHON_VERSIONS = ["3.9", "3.11"]
57+
SYSTEM_TEST_PYTHON_VERSIONS = ["3.9", "3.12"]
5858
SYSTEM_TEST_STANDARD_DEPENDENCIES = [
5959
"jinja2",
6060
"mock",

owlbot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
# Add templated files
3131
# ----------------------------------------------------------------------------
3232
templated_files = common.py_library(
33-
unit_test_python_versions=["3.9", "3.10", "3.11"],
34-
system_test_python_versions=["3.9", "3.11"],
33+
unit_test_python_versions=["3.9", "3.10", "3.11", "3.12"],
34+
system_test_python_versions=["3.9", "3.11", "3.12"],
3535
cov_level=35,
3636
intersphinx_dependencies={
3737
"pandas": "https://pandas.pydata.org/pandas-docs/stable/",

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"Programming Language :: Python :: 3.9",
114114
"Programming Language :: Python :: 3.10",
115115
"Programming Language :: Python :: 3.11",
116+
"Programming Language :: Python :: 3.12",
116117
"Operating System :: OS Independent",
117118
"Topic :: Internet",
118119
],

testing/constraints-3.12.txt

Whitespace-only changes.

tests/system/small/test_dataframe.py

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import io
1616
import operator
17+
import sys
1718
import tempfile
1819
import typing
1920
from typing import Tuple
@@ -4003,6 +4004,13 @@ def test_df_dot_operator_series(
40034004
)
40044005

40054006

4007+
# TODO(tswast): We may be able to re-enable this test after we break large
4008+
# queries up in https://github.com/googleapis/python-bigquery-dataframes/pull/427
4009+
@pytest.mark.skipif(
4010+
sys.version_info >= (3, 12),
4011+
# See: https://github.com/python/cpython/issues/112282
4012+
reason="setrecursionlimit has no effect on the Python C stack since Python 3.12.",
4013+
)
40064014
def test_recursion_limit(scalars_df_index):
40074015
scalars_df_index = scalars_df_index[["int64_too", "int64_col", "float64_col"]]
40084016
for i in range(400):

0 commit comments

Comments
 (0)