From ef8e0268f922ffcb7b66977e01e4f95c49a60824 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Fri, 18 Oct 2024 12:10:24 -0600 Subject: [PATCH 1/4] Test free-threaded build on all PRs --- .github/workflows/ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfe2c0f6b39..a6d110a285f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -555,7 +555,7 @@ jobs: - run: python3 -m nox -s test test-free-threaded: - if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }} + if: github.ref != 'refs/heads/main' needs: [fmt] runs-on: ubuntu-latest env: @@ -568,11 +568,13 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: components: rust-src - # TODO: replace with setup-python when there is support - - uses: deadsnakes/action@v3.2.0 - with: - python-version: '3.13-dev' - nogil: true + - uses: astral-sh/setup-uv@f3bcaebff5eace81a1c062af9f9011aae482ca9d + - run: | + uv python install 3.13t + uv venv --python 3.13t + uv pip install pip + . .venv/bin/activate + echo PATH=$PATH >> $GITHUB_ENV - run: python3 -m sysconfig - run: python3 -m pip install --upgrade pip && pip install nox - run: nox -s ffi-check From 592fde4cc26af7663310da44a8f856f775109219 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Fri, 18 Oct 2024 12:49:19 -0600 Subject: [PATCH 2/4] go back to deadsnakes --- .github/workflows/ci.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6d110a285f..3c3bfd50527 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -568,13 +568,11 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: components: rust-src - - uses: astral-sh/setup-uv@f3bcaebff5eace81a1c062af9f9011aae482ca9d - - run: | - uv python install 3.13t - uv venv --python 3.13t - uv pip install pip - . .venv/bin/activate - echo PATH=$PATH >> $GITHUB_ENV + # TODO: replace with setup-python when there is support + - uses: deadsnakes/action@v3.2.0 + with: + python-version: '3.13-dev' + nogil: true - run: python3 -m sysconfig - run: python3 -m pip install --upgrade pip && pip install nox - run: nox -s ffi-check From 55aeddebdce79dcca68a07707b9678d3adef81ee Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Fri, 18 Oct 2024 15:10:18 -0600 Subject: [PATCH 3/4] respond to review comments --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c3bfd50527..1efe6b06db1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -555,7 +555,6 @@ jobs: - run: python3 -m nox -s test test-free-threaded: - if: github.ref != 'refs/heads/main' needs: [fmt] runs-on: ubuntu-latest env: From c94c2cf4e9dc7a0d3b10f71e490110887eb822e1 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Fri, 18 Oct 2024 15:10:29 -0600 Subject: [PATCH 4/4] skip abi3 tests on free-threaded build --- noxfile.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/noxfile.py b/noxfile.py index 17ffb9aba85..f29bb45c109 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,6 +5,7 @@ import shutil import subprocess import sys +import sysconfig import tempfile from functools import lru_cache from glob import glob @@ -32,6 +33,7 @@ PYO3_DOCS_TARGET = PYO3_TARGET / "doc" PY_VERSIONS = ("3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13") PYPY_VERSIONS = ("3.9", "3.10") +FREE_THREADED_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED")) @nox.session(venv_backend="none") @@ -48,10 +50,14 @@ def test_rust(session: nox.Session): _run_cargo_test(session, package="pyo3-ffi") _run_cargo_test(session) - _run_cargo_test(session, features="abi3") + # the free-threaded build ignores abi3, so we skip abi3 + # tests to avoid unnecessarily running the tests twice + if not FREE_THREADED_BUILD: + _run_cargo_test(session, features="abi3") if "skip-full" not in session.posargs: _run_cargo_test(session, features="full") - _run_cargo_test(session, features="abi3 full") + if not FREE_THREADED_BUILD: + _run_cargo_test(session, features="abi3 full") @nox.session(name="test-py", venv_backend="none")