From 06af03bed1fc5586c9cfcf14944eb9e68aa28bd5 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 14:37:49 +0100 Subject: [PATCH 01/18] test adding cython to ci --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ src/_tests/cython/foobar.pyx | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/_tests/cython/foobar.pyx diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fabc57b9c2..40c7a374b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -204,6 +204,26 @@ jobs: name: Alpine flags: Alpine,3.12 + Cython: + name: "Cython" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup python + uses: actions/setup-python@v4 + - name: install cython + run: | + python -m pip install --upgrade pip + python -m pip install cython + - name: install trio + # use -e? + run: python -m pip install . + - name: compile pyx file + run: cythonize -i src/_tests/cython/test_cython.pyx + - name: import & run module + run: python -c 'import test_cython' + # https://github.com/marketplace/actions/alls-green#why check: # This job does nothing and is only used for the branch protection diff --git a/src/_tests/cython/foobar.pyx b/src/_tests/cython/foobar.pyx new file mode 100644 index 0000000000..538fe55739 --- /dev/null +++ b/src/_tests/cython/foobar.pyx @@ -0,0 +1,20 @@ +# cython: language_level=3 +import trio + +async def foo() -> None: + print('.') + +async def trio_main() -> None: + print('hello...') + await trio.sleep(1) + print(' world !') + + async with trio.open_nursery() as nursery: + nursery.start_soon(foo) + nursery.start_soon(foo) + nursery.start_soon(foo) + +def main() -> None: + trio.run(trio_main) + +main() From eb94b296a2961a3c41910c21a502489f0a7120d1 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 14:41:53 +0100 Subject: [PATCH 02/18] move the file, refer to it correctly --- .github/workflows/ci.yml | 392 +++++++++--------- .../cython/test_cython.pyx | 0 2 files changed, 196 insertions(+), 196 deletions(-) rename src/_tests/cython/foobar.pyx => tests/cython/test_cython.pyx (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40c7a374b7..47cc32b305 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,198 +11,198 @@ concurrency: cancel-in-progress: true jobs: - Windows: - name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})' - timeout-minutes: 20 - runs-on: 'windows-latest' - strategy: - fail-fast: false - matrix: - # pypy 3.9 and 3.10 are failing, see https://github.com/python-trio/trio/issues/2678 and https://github.com/python-trio/trio/issues/2776 respectively - python: ['3.8', '3.9', '3.10'] #, 'pypy-3.9-nightly', 'pypy-3.10-nightly'] - arch: ['x86', 'x64'] - lsp: [''] - lsp_extract_file: [''] - extra_name: [''] - exclude: - # pypy does not release 32-bit binaries - - python: 'pypy-3.9-nightly' - arch: 'x86' - #- python: 'pypy-3.10-nightly' - # arch: 'x86' - include: - - python: '3.8' - arch: 'x64' - lsp: 'https://raw.githubusercontent.com/python-trio/trio-ci-assets/master/komodia-based-vpn-setup.zip' - lsp_extract_file: 'komodia-based-vpn-setup.exe' - extra_name: ', with Komodia LSP' - - python: '3.8' - arch: 'x64' - lsp: 'https://www.proxifier.com/download/legacy/ProxifierSetup342.exe' - lsp_extract_file: '' - extra_name: ', with IFS LSP' - #- python: '3.8' - # arch: 'x64' - # lsp: 'http://download.pctools.com/mirror/updates/9.0.0.2308-SDavfree-lite_en.exe' - # lsp_extract_file: '' - # extra_name: ', with non-IFS LSP' - continue-on-error: >- - ${{ - ( - endsWith(matrix.python, '-dev') - || endsWith(matrix.python, '-nightly') - ) - && true - || false - }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup python - uses: actions/setup-python@v4 - with: - # This allows the matrix to specify just the major.minor version while still - # expanding it to get the latest patch version including alpha releases. - # This avoids the need to update for each new alpha, beta, release candidate, - # and then finally an actual release version. actions/setup-python doesn't - # support this for PyPy presently so we get no help there. - # - # 'CPython' -> '3.9.0-alpha - 3.9.X' - # 'PyPy' -> 'pypy-3.9' - python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} - architecture: '${{ matrix.arch }}' - cache: pip - cache-dependency-path: test-requirements.txt - - name: Run tests - run: ./ci.sh - shell: bash - env: - LSP: '${{ matrix.lsp }}' - LSP_EXTRACT_FILE: '${{ matrix.lsp_extract_file }}' - - if: always() - uses: codecov/codecov-action@v3 - with: - directory: empty - token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 - name: Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }}) - flags: Windows,${{ matrix.python }} - - Ubuntu: - name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})' - timeout-minutes: 10 - runs-on: 'ubuntu-latest' - strategy: - fail-fast: false - matrix: - python: ['pypy-3.9', 'pypy-3.10', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9-nightly', 'pypy-3.10-nightly'] - check_formatting: ['0'] - no_test_requirements: ['0'] - extra_name: [''] - include: - - python: '3.8' - check_formatting: '1' - extra_name: ', check formatting' - # separate test run that doesn't install test-requirements.txt - - python: '3.8' - no_test_requirements: '1' - extra_name: ', no test-requirements' - continue-on-error: >- - ${{ - ( - endsWith(matrix.python, '-dev') - || endsWith(matrix.python, '-nightly') - ) - && true - || false - }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup python - uses: actions/setup-python@v4 - if: "!endsWith(matrix.python, '-dev')" - with: - python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} - cache: pip - cache-dependency-path: test-requirements.txt - - name: Setup python (dev) - uses: deadsnakes/action@v2.0.2 - if: endsWith(matrix.python, '-dev') - with: - python-version: '${{ matrix.python }}' - - name: Run tests - run: ./ci.sh - env: - CHECK_FORMATTING: '${{ matrix.check_formatting }}' - NO_TEST_REQUIREMENTS: '${{ matrix.no_test_requirements }}' - - if: always() - uses: codecov/codecov-action@v3 - with: - directory: empty - token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 - name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }}) - flags: Ubuntu,${{ matrix.python }} - - macOS: - name: 'macOS (${{ matrix.python }})' - timeout-minutes: 15 - runs-on: 'macos-latest' - strategy: - fail-fast: false - matrix: - python: ['3.8', '3.9', '3.10', 'pypy-3.9-nightly', 'pypy-3.10-nightly'] - continue-on-error: >- - ${{ - ( - endsWith(matrix.python, '-dev') - || endsWith(matrix.python, '-nightly') - ) - && true - || false - }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup python - uses: actions/setup-python@v4 - with: - python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} - cache: pip - cache-dependency-path: test-requirements.txt - - name: Run tests - run: ./ci.sh - - if: always() - uses: codecov/codecov-action@v3 - with: - directory: empty - token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 - name: macOS (${{ matrix.python }}) - flags: macOS,${{ matrix.python }} - - # run CI on a musl linux - Alpine: - name: "Alpine" - runs-on: ubuntu-latest - container: alpine - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install necessary packages - # can't use setup-python because that python doesn't seem to work; - # `python3-dev` (rather than `python:alpine`) for some ctypes reason, - # `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test). - run: apk update && apk add python3-dev bash nodejs - - name: Enter virtual environment - run: python -m venv .venv - - name: Run tests - run: source .venv/bin/activate && ./ci.sh - - if: always() - uses: codecov/codecov-action@v3 - with: - directory: empty - token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 - name: Alpine - flags: Alpine,3.12 + # Windows: + # name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})' + # timeout-minutes: 20 + # runs-on: 'windows-latest' + # strategy: + # fail-fast: false + # matrix: + # # pypy 3.9 and 3.10 are failing, see https://github.com/python-trio/trio/issues/2678 and https://github.com/python-trio/trio/issues/2776 respectively + # python: ['3.8', '3.9', '3.10'] #, 'pypy-3.9-nightly', 'pypy-3.10-nightly'] + # arch: ['x86', 'x64'] + # lsp: [''] + # lsp_extract_file: [''] + # extra_name: [''] + # exclude: + # # pypy does not release 32-bit binaries + # - python: 'pypy-3.9-nightly' + # arch: 'x86' + # #- python: 'pypy-3.10-nightly' + # # arch: 'x86' + # include: + # - python: '3.8' + # arch: 'x64' + # lsp: 'https://raw.githubusercontent.com/python-trio/trio-ci-assets/master/komodia-based-vpn-setup.zip' + # lsp_extract_file: 'komodia-based-vpn-setup.exe' + # extra_name: ', with Komodia LSP' + # - python: '3.8' + # arch: 'x64' + # lsp: 'https://www.proxifier.com/download/legacy/ProxifierSetup342.exe' + # lsp_extract_file: '' + # extra_name: ', with IFS LSP' + # #- python: '3.8' + # # arch: 'x64' + # # lsp: 'http://download.pctools.com/mirror/updates/9.0.0.2308-SDavfree-lite_en.exe' + # # lsp_extract_file: '' + # # extra_name: ', with non-IFS LSP' + # continue-on-error: >- + # ${{ + # ( + # endsWith(matrix.python, '-dev') + # || endsWith(matrix.python, '-nightly') + # ) + # && true + # || false + # }} + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Setup python + # uses: actions/setup-python@v4 + # with: + # # This allows the matrix to specify just the major.minor version while still + # # expanding it to get the latest patch version including alpha releases. + # # This avoids the need to update for each new alpha, beta, release candidate, + # # and then finally an actual release version. actions/setup-python doesn't + # # support this for PyPy presently so we get no help there. + # # + # # 'CPython' -> '3.9.0-alpha - 3.9.X' + # # 'PyPy' -> 'pypy-3.9' + # python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} + # architecture: '${{ matrix.arch }}' + # cache: pip + # cache-dependency-path: test-requirements.txt + # - name: Run tests + # run: ./ci.sh + # shell: bash + # env: + # LSP: '${{ matrix.lsp }}' + # LSP_EXTRACT_FILE: '${{ matrix.lsp_extract_file }}' + # - if: always() + # uses: codecov/codecov-action@v3 + # with: + # directory: empty + # token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 + # name: Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }}) + # flags: Windows,${{ matrix.python }} + # + # Ubuntu: + # name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})' + # timeout-minutes: 10 + # runs-on: 'ubuntu-latest' + # strategy: + # fail-fast: false + # matrix: + # python: ['pypy-3.9', 'pypy-3.10', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9-nightly', 'pypy-3.10-nightly'] + # check_formatting: ['0'] + # no_test_requirements: ['0'] + # extra_name: [''] + # include: + # - python: '3.8' + # check_formatting: '1' + # extra_name: ', check formatting' + # # separate test run that doesn't install test-requirements.txt + # - python: '3.8' + # no_test_requirements: '1' + # extra_name: ', no test-requirements' + # continue-on-error: >- + # ${{ + # ( + # endsWith(matrix.python, '-dev') + # || endsWith(matrix.python, '-nightly') + # ) + # && true + # || false + # }} + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Setup python + # uses: actions/setup-python@v4 + # if: "!endsWith(matrix.python, '-dev')" + # with: + # python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} + # cache: pip + # cache-dependency-path: test-requirements.txt + # - name: Setup python (dev) + # uses: deadsnakes/action@v2.0.2 + # if: endsWith(matrix.python, '-dev') + # with: + # python-version: '${{ matrix.python }}' + # - name: Run tests + # run: ./ci.sh + # env: + # CHECK_FORMATTING: '${{ matrix.check_formatting }}' + # NO_TEST_REQUIREMENTS: '${{ matrix.no_test_requirements }}' + # - if: always() + # uses: codecov/codecov-action@v3 + # with: + # directory: empty + # token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 + # name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }}) + # flags: Ubuntu,${{ matrix.python }} + # + # macOS: + # name: 'macOS (${{ matrix.python }})' + # timeout-minutes: 15 + # runs-on: 'macos-latest' + # strategy: + # fail-fast: false + # matrix: + # python: ['3.8', '3.9', '3.10', 'pypy-3.9-nightly', 'pypy-3.10-nightly'] + # continue-on-error: >- + # ${{ + # ( + # endsWith(matrix.python, '-dev') + # || endsWith(matrix.python, '-nightly') + # ) + # && true + # || false + # }} + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Setup python + # uses: actions/setup-python@v4 + # with: + # python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} + # cache: pip + # cache-dependency-path: test-requirements.txt + # - name: Run tests + # run: ./ci.sh + # - if: always() + # uses: codecov/codecov-action@v3 + # with: + # directory: empty + # token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 + # name: macOS (${{ matrix.python }}) + # flags: macOS,${{ matrix.python }} + # + # # run CI on a musl linux + # Alpine: + # name: "Alpine" + # runs-on: ubuntu-latest + # container: alpine + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Install necessary packages + # # can't use setup-python because that python doesn't seem to work; + # # `python3-dev` (rather than `python:alpine`) for some ctypes reason, + # # `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test). + # run: apk update && apk add python3-dev bash nodejs + # - name: Enter virtual environment + # run: python -m venv .venv + # - name: Run tests + # run: source .venv/bin/activate && ./ci.sh + # - if: always() + # uses: codecov/codecov-action@v3 + # with: + # directory: empty + # token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 + # name: Alpine + # flags: Alpine,3.12 Cython: name: "Cython" @@ -220,7 +220,7 @@ jobs: # use -e? run: python -m pip install . - name: compile pyx file - run: cythonize -i src/_tests/cython/test_cython.pyx + run: cythonize -i tests/cython/test_cython.pyx - name: import & run module run: python -c 'import test_cython' @@ -230,9 +230,9 @@ jobs: if: always() needs: - - Windows - - Ubuntu - - macOS + #- Windows + #- Ubuntu + #- macOS - Alpine runs-on: ubuntu-latest diff --git a/src/_tests/cython/foobar.pyx b/tests/cython/test_cython.pyx similarity index 100% rename from src/_tests/cython/foobar.pyx rename to tests/cython/test_cython.pyx From ab147c477588118d8e1f2209864b346e3e108f37 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 14:42:29 +0100 Subject: [PATCH 03/18] need cython --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47cc32b305..e538e9b8e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -233,7 +233,8 @@ jobs: #- Windows #- Ubuntu #- macOS - - Alpine + #- Alpine + - Cython runs-on: ubuntu-latest From c554f5ff2d54ddfe9af6fcf1014a835b05c2b9b4 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 14:47:55 +0100 Subject: [PATCH 04/18] import from correct location --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e538e9b8e4..c2ebaadb1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,7 +222,7 @@ jobs: - name: compile pyx file run: cythonize -i tests/cython/test_cython.pyx - name: import & run module - run: python -c 'import test_cython' + run: python -c 'import tests.cython.test_cython' # https://github.com/marketplace/actions/alls-green#why check: # This job does nothing and is only used for the branch protection From 6ee97f0d5cdd89caaf7a33d5d797eddc2c0c3b75 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 14:56:45 +0100 Subject: [PATCH 05/18] matrixify cython, specify python-version, revert cython-specific fix to make sure we can repro the error --- .github/workflows/ci.yml | 9 ++++++++- src/trio/_core/_run.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2ebaadb1d..afe858cdb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -207,15 +207,22 @@ jobs: Cython: name: "Cython" runs-on: ubuntu-latest + matrix: + cython: ['0.29.14', '<3', '>=3'] steps: - name: Checkout uses: actions/checkout@v3 - name: Setup python uses: actions/setup-python@v4 + with: + python-version: 3 + architecture: '${{ matrix.arch }}' + cache: pip + cache-dependency-path: test-requirements.txt - name: install cython run: | python -m pip install --upgrade pip - python -m pip install cython + python -m pip install cython${{ matrix.cython}} - name: install trio # use -e? run: python -m pip install . diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py index 7ebfc9cf80..7010891c59 100644 --- a/src/trio/_core/_run.py +++ b/src/trio/_core/_run.py @@ -1757,7 +1757,7 @@ def spawn_impl( except AttributeError: name = repr(name) - if getattr(coro, "cr_frame", None) is None: + if hasattr(coro, "cr_frame"): # This async function is implemented in C or Cython async def python_wrapper(orig_coro: Awaitable[RetT]) -> RetT: return await orig_coro From eb4489d0e90494a5c788a00da17eb5e2eaf11822 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 14:58:01 +0100 Subject: [PATCH 06/18] matrix must be inside strategy --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afe858cdb9..63a8201419 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -207,8 +207,9 @@ jobs: Cython: name: "Cython" runs-on: ubuntu-latest - matrix: - cython: ['0.29.14', '<3', '>=3'] + strategy: + matrix: + cython: ['0.29.14', '<3', '>=3'] steps: - name: Checkout uses: actions/checkout@v3 From 4305bbb49a916b725d899ee8244c58d35fdaac76 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 15:00:06 +0100 Subject: [PATCH 07/18] fail-fast false, fix ==version check --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63a8201419..fe4731cce8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -208,8 +208,9 @@ jobs: name: "Cython" runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - cython: ['0.29.14', '<3', '>=3'] + cython: ['==0.29.14', '<3', '>=3'] steps: - name: Checkout uses: actions/checkout@v3 From 0d5e899300e376a85e9fc436186d859b044ad861 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 15:01:58 +0100 Subject: [PATCH 08/18] remove accidental architecture copypaste, bump minimum version --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe4731cce8..0691225181 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,7 +210,7 @@ jobs: strategy: fail-fast: false matrix: - cython: ['==0.29.14', '<3', '>=3'] + cython: ['==0.29.15', '<3', '>=3'] steps: - name: Checkout uses: actions/checkout@v3 @@ -218,7 +218,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: 3 - architecture: '${{ matrix.arch }}' cache: pip cache-dependency-path: test-requirements.txt - name: install cython From e9f81c341fecd3799ca57452941aa925f6b4ecbd Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 15:04:47 +0100 Subject: [PATCH 09/18] quote matrix.cython to avoid <3 being parsed as a stdin redirect, explicitly install distutils --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0691225181..2e07e49bd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,8 +222,8 @@ jobs: cache-dependency-path: test-requirements.txt - name: install cython run: | - python -m pip install --upgrade pip - python -m pip install cython${{ matrix.cython}} + python -m pip install --upgrade pip distutils + python -m pip install "cython${{ matrix.cython}}" - name: install trio # use -e? run: python -m pip install . From 4f23772af3cedfb181bcc2457f4a5e2a5bf84141 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 15:06:57 +0100 Subject: [PATCH 10/18] setuptools is apparently how you get distutils --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e07e49bd4..3662fe2277 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -222,7 +222,8 @@ jobs: cache-dependency-path: test-requirements.txt - name: install cython run: | - python -m pip install --upgrade pip distutils + # setuptools is needed to get distutils on 3.12 + python -m pip install --upgrade pip setuptools python -m pip install "cython${{ matrix.cython}}" - name: install trio # use -e? From 7aca3541064db84311ccce2bff2ea93756c2aafa Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 15:09:37 +0100 Subject: [PATCH 11/18] matrixify 3.8, 3.10, 3[.12] --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3662fe2277..507749cf73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -211,13 +211,14 @@ jobs: fail-fast: false matrix: cython: ['==0.29.15', '<3', '>=3'] + python: ['3.8', '3.10', '3'] steps: - name: Checkout uses: actions/checkout@v3 - name: Setup python uses: actions/setup-python@v4 with: - python-version: 3 + python-version: '${{ matrix.python }}' cache: pip cache-dependency-path: test-requirements.txt - name: install cython From e320cc7d70e7687edf96b1d3f0bc0b7d52bf1718 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 15:11:50 +0100 Subject: [PATCH 12/18] test more old cython versions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 507749cf73..1c132b9f9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,7 +210,7 @@ jobs: strategy: fail-fast: false matrix: - cython: ['==0.29.15', '<3', '>=3'] + cython: ['==0.29.16', '==0.29.20', '==0.29.23', '==0.29.24', '<3', '>=3'] python: ['3.8', '3.10', '3'] steps: - name: Checkout From 3aabf38983d8840a13bec59b89b9dff27c327b61 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 15:19:22 +0100 Subject: [PATCH 13/18] AlL tHe VeRsIoNs --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c132b9f9f..b464fa535f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,8 +210,8 @@ jobs: strategy: fail-fast: false matrix: - cython: ['==0.29.16', '==0.29.20', '==0.29.23', '==0.29.24', '<3', '>=3'] - python: ['3.8', '3.10', '3'] + cython: ['==0.29.23', '==0.29.26', '==0.29.30', '<3', '>=3'] + python: ['3.8', '3.10', '3.11', '3'] steps: - name: Checkout uses: actions/checkout@v3 From aedec0b3509ae633cbfbade4a79662bc8a99dea2 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 15:51:26 +0100 Subject: [PATCH 14/18] properly revert the fix --- src/trio/_core/_run.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py index 7010891c59..88f9725a80 100644 --- a/src/trio/_core/_run.py +++ b/src/trio/_core/_run.py @@ -1756,8 +1756,7 @@ def spawn_impl( name = f"{name.__module__}.{name.__qualname__}" # type: ignore[attr-defined] except AttributeError: name = repr(name) - - if hasattr(coro, "cr_frame"): + if not hasattr(coro, "cr_frame"): # This async function is implemented in C or Cython async def python_wrapper(orig_coro: Awaitable[RetT]) -> RetT: return await orig_coro From d72d394e2be985fcae27f981325ff8da10ed76d6 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 31 Jan 2024 16:04:55 +0100 Subject: [PATCH 15/18] use checkout@v4 and setup-python@v5, and remove cache-dependency-path .. idk really what difference that could make --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b464fa535f..af2fd4ee20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -214,13 +214,12 @@ jobs: python: ['3.8', '3.10', '3.11', '3'] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '${{ matrix.python }}' cache: pip - cache-dependency-path: test-requirements.txt - name: install cython run: | # setuptools is needed to get distutils on 3.12 From 23a8c24be822c9a5058dfaecd79e0bc0942eee09 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 6 Feb 2024 12:02:58 +0100 Subject: [PATCH 16/18] strip down CI, add comments, remove redundant code in the pyx file --- .github/workflows/ci.yml | 10 ++++------ tests/cython/test_cython.pyx | 10 ++++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af2fd4ee20..38d648169b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,8 +210,8 @@ jobs: strategy: fail-fast: false matrix: - cython: ['==0.29.23', '==0.29.26', '==0.29.30', '<3', '>=3'] - python: ['3.8', '3.10', '3.11', '3'] + cython: ['<3', '>=3'] + python: ['3.8', '3.12'] steps: - name: Checkout uses: actions/checkout@v4 @@ -222,11 +222,9 @@ jobs: cache: pip - name: install cython run: | - # setuptools is needed to get distutils on 3.12 - python -m pip install --upgrade pip setuptools - python -m pip install "cython${{ matrix.cython}}" + # setuptools is needed to get distutils on 3.12, which cythonize requires + python -m pip install setuptools "cython${{ matrix.cython}}" - name: install trio - # use -e? run: python -m pip install . - name: compile pyx file run: cythonize -i tests/cython/test_cython.pyx diff --git a/tests/cython/test_cython.pyx b/tests/cython/test_cython.pyx index 538fe55739..b836caf90c 100644 --- a/tests/cython/test_cython.pyx +++ b/tests/cython/test_cython.pyx @@ -1,6 +1,11 @@ # cython: language_level=3 import trio +# the output of the prints are not currently checked, we only check +# if the program can be compiled and doesn't crash when run. + +# The content of the program can easily be extended if there's other behaviour +# that might be likely to be problematic for cython. async def foo() -> None: print('.') @@ -14,7 +19,4 @@ async def trio_main() -> None: nursery.start_soon(foo) nursery.start_soon(foo) -def main() -> None: - trio.run(trio_main) - -main() +trio.run(trio_main) From 93800d351951f5c82225268be2b4dfc296074539 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 6 Feb 2024 12:09:33 +0100 Subject: [PATCH 17/18] de-matrix cython version --- .github/workflows/ci.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38d648169b..2b30df32e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,7 +210,6 @@ jobs: strategy: fail-fast: false matrix: - cython: ['<3', '>=3'] python: ['3.8', '3.12'] steps: - name: Checkout @@ -220,12 +219,19 @@ jobs: with: python-version: '${{ matrix.python }}' cache: pip - - name: install cython - run: | # setuptools is needed to get distutils on 3.12, which cythonize requires - python -m pip install setuptools "cython${{ matrix.cython}}" - - name: install trio - run: python -m pip install . + - name: install trio and setuptools + run: python -m pip install . setuptools + + - name: install cython<3 + run: python -m pip install "cython<3" + - name: compile pyx file + run: cythonize -i tests/cython/test_cython.pyx + - name: import & run module + run: python -c 'import tests.cython.test_cython' + + - name: install cython>=3 + run: python -m pip install "cython>=3" - name: compile pyx file run: cythonize -i tests/cython/test_cython.pyx - name: import & run module From 4d62c1720a114186cd724024539231b8ad260f4e Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 6 Feb 2024 12:20:39 +0100 Subject: [PATCH 18/18] undo reversion of 2911, add comment on cython version. Undo commenting out other workflows. --- .github/workflows/ci.yml | 399 ++++++++++++++++++++------------------- src/trio/_core/_run.py | 4 +- 2 files changed, 203 insertions(+), 200 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b30df32e9..2732712eb0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,198 +11,198 @@ concurrency: cancel-in-progress: true jobs: - # Windows: - # name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})' - # timeout-minutes: 20 - # runs-on: 'windows-latest' - # strategy: - # fail-fast: false - # matrix: - # # pypy 3.9 and 3.10 are failing, see https://github.com/python-trio/trio/issues/2678 and https://github.com/python-trio/trio/issues/2776 respectively - # python: ['3.8', '3.9', '3.10'] #, 'pypy-3.9-nightly', 'pypy-3.10-nightly'] - # arch: ['x86', 'x64'] - # lsp: [''] - # lsp_extract_file: [''] - # extra_name: [''] - # exclude: - # # pypy does not release 32-bit binaries - # - python: 'pypy-3.9-nightly' - # arch: 'x86' - # #- python: 'pypy-3.10-nightly' - # # arch: 'x86' - # include: - # - python: '3.8' - # arch: 'x64' - # lsp: 'https://raw.githubusercontent.com/python-trio/trio-ci-assets/master/komodia-based-vpn-setup.zip' - # lsp_extract_file: 'komodia-based-vpn-setup.exe' - # extra_name: ', with Komodia LSP' - # - python: '3.8' - # arch: 'x64' - # lsp: 'https://www.proxifier.com/download/legacy/ProxifierSetup342.exe' - # lsp_extract_file: '' - # extra_name: ', with IFS LSP' - # #- python: '3.8' - # # arch: 'x64' - # # lsp: 'http://download.pctools.com/mirror/updates/9.0.0.2308-SDavfree-lite_en.exe' - # # lsp_extract_file: '' - # # extra_name: ', with non-IFS LSP' - # continue-on-error: >- - # ${{ - # ( - # endsWith(matrix.python, '-dev') - # || endsWith(matrix.python, '-nightly') - # ) - # && true - # || false - # }} - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Setup python - # uses: actions/setup-python@v4 - # with: - # # This allows the matrix to specify just the major.minor version while still - # # expanding it to get the latest patch version including alpha releases. - # # This avoids the need to update for each new alpha, beta, release candidate, - # # and then finally an actual release version. actions/setup-python doesn't - # # support this for PyPy presently so we get no help there. - # # - # # 'CPython' -> '3.9.0-alpha - 3.9.X' - # # 'PyPy' -> 'pypy-3.9' - # python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} - # architecture: '${{ matrix.arch }}' - # cache: pip - # cache-dependency-path: test-requirements.txt - # - name: Run tests - # run: ./ci.sh - # shell: bash - # env: - # LSP: '${{ matrix.lsp }}' - # LSP_EXTRACT_FILE: '${{ matrix.lsp_extract_file }}' - # - if: always() - # uses: codecov/codecov-action@v3 - # with: - # directory: empty - # token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 - # name: Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }}) - # flags: Windows,${{ matrix.python }} - # - # Ubuntu: - # name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})' - # timeout-minutes: 10 - # runs-on: 'ubuntu-latest' - # strategy: - # fail-fast: false - # matrix: - # python: ['pypy-3.9', 'pypy-3.10', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9-nightly', 'pypy-3.10-nightly'] - # check_formatting: ['0'] - # no_test_requirements: ['0'] - # extra_name: [''] - # include: - # - python: '3.8' - # check_formatting: '1' - # extra_name: ', check formatting' - # # separate test run that doesn't install test-requirements.txt - # - python: '3.8' - # no_test_requirements: '1' - # extra_name: ', no test-requirements' - # continue-on-error: >- - # ${{ - # ( - # endsWith(matrix.python, '-dev') - # || endsWith(matrix.python, '-nightly') - # ) - # && true - # || false - # }} - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Setup python - # uses: actions/setup-python@v4 - # if: "!endsWith(matrix.python, '-dev')" - # with: - # python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} - # cache: pip - # cache-dependency-path: test-requirements.txt - # - name: Setup python (dev) - # uses: deadsnakes/action@v2.0.2 - # if: endsWith(matrix.python, '-dev') - # with: - # python-version: '${{ matrix.python }}' - # - name: Run tests - # run: ./ci.sh - # env: - # CHECK_FORMATTING: '${{ matrix.check_formatting }}' - # NO_TEST_REQUIREMENTS: '${{ matrix.no_test_requirements }}' - # - if: always() - # uses: codecov/codecov-action@v3 - # with: - # directory: empty - # token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 - # name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }}) - # flags: Ubuntu,${{ matrix.python }} - # - # macOS: - # name: 'macOS (${{ matrix.python }})' - # timeout-minutes: 15 - # runs-on: 'macos-latest' - # strategy: - # fail-fast: false - # matrix: - # python: ['3.8', '3.9', '3.10', 'pypy-3.9-nightly', 'pypy-3.10-nightly'] - # continue-on-error: >- - # ${{ - # ( - # endsWith(matrix.python, '-dev') - # || endsWith(matrix.python, '-nightly') - # ) - # && true - # || false - # }} - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Setup python - # uses: actions/setup-python@v4 - # with: - # python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} - # cache: pip - # cache-dependency-path: test-requirements.txt - # - name: Run tests - # run: ./ci.sh - # - if: always() - # uses: codecov/codecov-action@v3 - # with: - # directory: empty - # token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 - # name: macOS (${{ matrix.python }}) - # flags: macOS,${{ matrix.python }} - # - # # run CI on a musl linux - # Alpine: - # name: "Alpine" - # runs-on: ubuntu-latest - # container: alpine - # steps: - # - name: Checkout - # uses: actions/checkout@v3 - # - name: Install necessary packages - # # can't use setup-python because that python doesn't seem to work; - # # `python3-dev` (rather than `python:alpine`) for some ctypes reason, - # # `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test). - # run: apk update && apk add python3-dev bash nodejs - # - name: Enter virtual environment - # run: python -m venv .venv - # - name: Run tests - # run: source .venv/bin/activate && ./ci.sh - # - if: always() - # uses: codecov/codecov-action@v3 - # with: - # directory: empty - # token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 - # name: Alpine - # flags: Alpine,3.12 + Windows: + name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})' + timeout-minutes: 20 + runs-on: 'windows-latest' + strategy: + fail-fast: false + matrix: + # pypy 3.9 and 3.10 are failing, see https://github.com/python-trio/trio/issues/2678 and https://github.com/python-trio/trio/issues/2776 respectively + python: ['3.8', '3.9', '3.10'] #, 'pypy-3.9-nightly', 'pypy-3.10-nightly'] + arch: ['x86', 'x64'] + lsp: [''] + lsp_extract_file: [''] + extra_name: [''] + exclude: + # pypy does not release 32-bit binaries + - python: 'pypy-3.9-nightly' + arch: 'x86' + #- python: 'pypy-3.10-nightly' + # arch: 'x86' + include: + - python: '3.8' + arch: 'x64' + lsp: 'https://raw.githubusercontent.com/python-trio/trio-ci-assets/master/komodia-based-vpn-setup.zip' + lsp_extract_file: 'komodia-based-vpn-setup.exe' + extra_name: ', with Komodia LSP' + - python: '3.8' + arch: 'x64' + lsp: 'https://www.proxifier.com/download/legacy/ProxifierSetup342.exe' + lsp_extract_file: '' + extra_name: ', with IFS LSP' + #- python: '3.8' + # arch: 'x64' + # lsp: 'http://download.pctools.com/mirror/updates/9.0.0.2308-SDavfree-lite_en.exe' + # lsp_extract_file: '' + # extra_name: ', with non-IFS LSP' + continue-on-error: >- + ${{ + ( + endsWith(matrix.python, '-dev') + || endsWith(matrix.python, '-nightly') + ) + && true + || false + }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup python + uses: actions/setup-python@v4 + with: + # This allows the matrix to specify just the major.minor version while still + # expanding it to get the latest patch version including alpha releases. + # This avoids the need to update for each new alpha, beta, release candidate, + # and then finally an actual release version. actions/setup-python doesn't + # support this for PyPy presently so we get no help there. + # + # 'CPython' -> '3.9.0-alpha - 3.9.X' + # 'PyPy' -> 'pypy-3.9' + python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} + architecture: '${{ matrix.arch }}' + cache: pip + cache-dependency-path: test-requirements.txt + - name: Run tests + run: ./ci.sh + shell: bash + env: + LSP: '${{ matrix.lsp }}' + LSP_EXTRACT_FILE: '${{ matrix.lsp_extract_file }}' + - if: always() + uses: codecov/codecov-action@v3 + with: + directory: empty + token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 + name: Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }}) + flags: Windows,${{ matrix.python }} + + Ubuntu: + name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})' + timeout-minutes: 10 + runs-on: 'ubuntu-latest' + strategy: + fail-fast: false + matrix: + python: ['pypy-3.9', 'pypy-3.10', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9-nightly', 'pypy-3.10-nightly'] + check_formatting: ['0'] + no_test_requirements: ['0'] + extra_name: [''] + include: + - python: '3.8' + check_formatting: '1' + extra_name: ', check formatting' + # separate test run that doesn't install test-requirements.txt + - python: '3.8' + no_test_requirements: '1' + extra_name: ', no test-requirements' + continue-on-error: >- + ${{ + ( + endsWith(matrix.python, '-dev') + || endsWith(matrix.python, '-nightly') + ) + && true + || false + }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup python + uses: actions/setup-python@v4 + if: "!endsWith(matrix.python, '-dev')" + with: + python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} + cache: pip + cache-dependency-path: test-requirements.txt + - name: Setup python (dev) + uses: deadsnakes/action@v2.0.2 + if: endsWith(matrix.python, '-dev') + with: + python-version: '${{ matrix.python }}' + - name: Run tests + run: ./ci.sh + env: + CHECK_FORMATTING: '${{ matrix.check_formatting }}' + NO_TEST_REQUIREMENTS: '${{ matrix.no_test_requirements }}' + - if: always() + uses: codecov/codecov-action@v3 + with: + directory: empty + token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 + name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }}) + flags: Ubuntu,${{ matrix.python }} + + macOS: + name: 'macOS (${{ matrix.python }})' + timeout-minutes: 15 + runs-on: 'macos-latest' + strategy: + fail-fast: false + matrix: + python: ['3.8', '3.9', '3.10', 'pypy-3.9-nightly', 'pypy-3.10-nightly'] + continue-on-error: >- + ${{ + ( + endsWith(matrix.python, '-dev') + || endsWith(matrix.python, '-nightly') + ) + && true + || false + }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: ${{ fromJSON(format('["{0}", "{1}"]', format('{0}.0-alpha - {0}.X', matrix.python), matrix.python))[startsWith(matrix.python, 'pypy')] }} + cache: pip + cache-dependency-path: test-requirements.txt + - name: Run tests + run: ./ci.sh + - if: always() + uses: codecov/codecov-action@v3 + with: + directory: empty + token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 + name: macOS (${{ matrix.python }}) + flags: macOS,${{ matrix.python }} + + # run CI on a musl linux + Alpine: + name: "Alpine" + runs-on: ubuntu-latest + container: alpine + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install necessary packages + # can't use setup-python because that python doesn't seem to work; + # `python3-dev` (rather than `python:alpine`) for some ctypes reason, + # `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test). + run: apk update && apk add python3-dev bash nodejs + - name: Enter virtual environment + run: python -m venv .venv + - name: Run tests + run: source .venv/bin/activate && ./ci.sh + - if: always() + uses: codecov/codecov-action@v3 + with: + directory: empty + token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 + name: Alpine + flags: Alpine,3.12 Cython: name: "Cython" @@ -219,9 +219,9 @@ jobs: with: python-version: '${{ matrix.python }}' cache: pip - # setuptools is needed to get distutils on 3.12, which cythonize requires + # setuptools is needed to get distutils on 3.12, which cythonize requires - name: install trio and setuptools - run: python -m pip install . setuptools + run: python -m pip install --upgrade pip . setuptools - name: install cython<3 run: python -m pip install "cython<3" @@ -233,7 +233,8 @@ jobs: - name: install cython>=3 run: python -m pip install "cython>=3" - name: compile pyx file - run: cythonize -i tests/cython/test_cython.pyx + # different cython version should trigger a re-compile, but --force just in case + run: cythonize --inplace --force tests/cython/test_cython.pyx - name: import & run module run: python -c 'import tests.cython.test_cython' @@ -243,10 +244,10 @@ jobs: if: always() needs: - #- Windows - #- Ubuntu - #- macOS - #- Alpine + - Windows + - Ubuntu + - macOS + - Alpine - Cython runs-on: ubuntu-latest diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py index 9d71100964..c5d6b65712 100644 --- a/src/trio/_core/_run.py +++ b/src/trio/_core/_run.py @@ -1766,7 +1766,9 @@ def spawn_impl( name = f"{name.__module__}.{name.__qualname__}" # type: ignore[attr-defined] except AttributeError: name = repr(name) - if not hasattr(coro, "cr_frame"): + + # very old Cython versions (<0.29.24) has the attribute, but with a value of None + if getattr(coro, "cr_frame", None) is None: # This async function is implemented in C or Cython async def python_wrapper(orig_coro: Awaitable[RetT]) -> RetT: return await orig_coro