From 3b35eea10ce4f1fd68ff32ab5ebfdda2a5dd65a3 Mon Sep 17 00:00:00 2001 From: Vytautas Liuolia Date: Sun, 11 Aug 2024 23:49:17 +0200 Subject: [PATCH] chore(platform): declare CPython 3.13 support (#2263) * chore(platform): declare CPython 3.13 support * chore(platform): use a more specific interpreter version in Actions * chore(CI): specify a version range for py313 Action * test(test_hello.py): prevent an exception from getting raised during gc * chore(platform): demote 3.7 & 3.8 to best effort, add more 3.13 gates * chore(Actions): cleaner naming of pre-release Python gates --- .github/workflows/mintest.yaml | 9 ++++++++- .github/workflows/tests.yaml | 20 +++++++++++++++++--- CONTRIBUTING.md | 3 ++- docs/changes/4.0.0.rst | 14 +++++++++----- setup.cfg | 1 + tests/test_hello.py | 9 ++++++++- tox.ini | 8 ++++++++ 7 files changed, 53 insertions(+), 11 deletions(-) diff --git a/.github/workflows/mintest.yaml b/.github/workflows/mintest.yaml index cf2ff0d78..752ef2d38 100644 --- a/.github/workflows/mintest.yaml +++ b/.github/workflows/mintest.yaml @@ -15,10 +15,10 @@ jobs: fail-fast: false matrix: python-version: - - "3.8" - "3.10" - "3.11" - "3.12" + - "3.13" steps: - name: Checkout repo @@ -26,9 +26,16 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 + if: ${{ matrix.python-version != '3.13' }} with: python-version: ${{ matrix.python-version }} + - name: Set up Python 3.13 + uses: actions/setup-python@v4 + if: ${{ matrix.python-version == '3.13' }} + with: + python-version: "3.13.0-rc.1 - 3.13" + - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 135beda0b..8d01c927f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -19,6 +19,8 @@ jobs: matrix: python-version: - "3.12" + python-dev-version: + - "" os: - "ubuntu-latest" toxenv: @@ -56,9 +58,6 @@ jobs: - python-version: "3.8" os: ubuntu-latest toxenv: py38 - - python-version: "3.8" - os: ubuntu-latest - toxenv: py38_cython - python-version: "3.9" os: ubuntu-latest toxenv: py39 @@ -89,6 +88,14 @@ jobs: - python-version: "3.12" os: windows-latest toxenv: py312_nocover + - python-version: "3.13" + python-dev-version: "3.13.0-rc.1 - 3.13" + os: ubuntu-latest + toxenv: py313 + - python-version: "3.13" + python-dev-version: "3.13.0-rc.1 - 3.13" + os: ubuntu-latest + toxenv: py313_cython # These env require 3.8 and 20.04, see tox.ini - python-version: "3.8" os: ubuntu-20.04 @@ -112,9 +119,16 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 + if: ${{ !matrix.python-dev-version }} with: python-version: ${{ matrix.python-version }} + - name: Set up Python (pre-release) + uses: actions/setup-python@v4 + if: ${{ matrix.python-dev-version }} + with: + python-version: ${{ matrix.python-dev-version }} + - name: Install smoke test dependencies if: ${{ matrix.toxenv == 'py38_smoke' || matrix.toxenv == 'py38_smoke_cython' }} run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4748acef0..935c8aacb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,8 @@ $ pip install -U ruff $ ruff format ``` -You can check all this by running ``tox`` from within the Falcon project directory. Your environment must be based on CPython 3.8, 3.10, 3.11 or 3.12: +You can check all this by running ``tox`` from within the Falcon project directory. +Your environment must be based on CPython 3.10, 3.11, 3.12 or 3.13: ```bash $ pip install -U tox diff --git a/docs/changes/4.0.0.rst b/docs/changes/4.0.0.rst index 361c17619..9cdbf9913 100644 --- a/docs/changes/4.0.0.rst +++ b/docs/changes/4.0.0.rst @@ -14,12 +14,16 @@ Changes to Supported Platforms - CPython 3.11 is now fully supported. (`#2072 `__) - CPython 3.12 is now fully supported. (`#2196 `__) +- CPython 3.13 is now fully supported. (`#2258 `__) - End-of-life Python 3.5 & 3.6 are no longer supported. (`#2074 `__) -- Python 3.7 is no longer actively supported, but the framework should still - continue to install from source. We may remove the support for 3.7 altogether - later in the 4.x series if we are faced with incompatible ecosystem changes - in typing, Cython, etc. - +- End-of-life Python 3.7 and (soon end-of-life) 3.8 are no longer actively + supported, but the framework should still continue to install from source and + function. +- The Falcon 4.x series is guaranteed to support CPython 3.10 and + PyPy3.10 (v7.3.16). + This means that we may drop the support for Python 3.7-3.9 altogether in a + later 4.x release, especially if we are faced with incompatible ecosystem + changes in typing, Cython, etc. .. towncrier release notes start diff --git a/setup.cfg b/setup.cfg index 04059572e..41c3b93ab 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,6 +30,7 @@ classifiers = Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.12 + Programming Language :: Python :: 3.13 Programming Language :: Cython keywords = asgi diff --git a/tests/test_hello.py b/tests/test_hello.py index 1bef8d773..709b844b0 100644 --- a/tests/test_hello.py +++ b/tests/test_hello.py @@ -78,10 +78,17 @@ def close(self): self.close_called = True -class NonClosingBytesIO(io.BytesIO): +# NOTE(vytas): Do not inherit from BytesIO but encapsulate instead, as on +# CPython 3.13 garbage-collecting a BytesIO instance with an invalid .close() +# sometimes bubbles up a warning about exception when trying to call it. +class NonClosingBytesIO: # Not callable; test that CloseableStreamIterator ignores it close = False # type: ignore + def __init__(self, data=b''): + self._stream = io.BytesIO(data) + self.read = self._stream.read + class ClosingFilelikeHelloResource: sample_status = '200 OK' diff --git a/tox.ini b/tox.ini index 329e2b9d3..56a13d756 100644 --- a/tox.ini +++ b/tox.ini @@ -220,6 +220,14 @@ deps = {[with-cython]deps} setenv = {[with-cython]setenv} commands = {[with-cython]commands} +[testenv:py313_cython] +basepython = python3.13 +# NOTE(vytas): pyximport relies on distutils.extension +deps = {[with-cython]deps} + setuptools +setenv = {[with-cython]setenv} +commands = {[with-cython]commands} + # -------------------------------------------------------------------- # WSGI servers (Cythonized Falcon) # --------------------------------------------------------------------