From 563ecdf3f097a1add976d900ccc14440aae822f7 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Tue, 19 Nov 2024 14:55:56 -0700 Subject: [PATCH 1/4] declare support for free-threading --- .github/workflows/CI.yml | 30 +++++++++++++----------------- noxfile.py | 2 +- src/lib.rs | 2 +- tests/requirements.in | 1 + tests/requirements.txt | 6 +++++- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 895b48c..5a7f65a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -80,7 +80,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -88,6 +88,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -95,7 +96,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' sccache: "true" manylinux: auto - name: Upload wheels @@ -117,7 +118,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -125,6 +126,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -132,7 +134,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' manylinux: musllinux_1_2 sccache: "true" - name: Upload wheels @@ -151,7 +153,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -159,6 +161,7 @@ jobs: 3.11 3.12 3.13 + 3.13t ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} allow-prereleases: true @@ -167,7 +170,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -185,7 +188,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -193,6 +196,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -200,7 +204,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -217,15 +221,7 @@ jobs: persist-credentials: false - uses: actions/setup-python@v5 with: - python-version: | - 3.9 - 3.10 - 3.11 - 3.12 - 3.13 - pypy3.9 - pypy3.10 - allow-prereleases: true + python-version: 3.13 - name: Build an sdist uses: PyO3/maturin-action@v1 with: diff --git a/noxfile.py b/noxfile.py index 0a708de..0ec7240 100644 --- a/noxfile.py +++ b/noxfile.py @@ -72,7 +72,7 @@ def tests(session): stdout=summary, ) else: - session.run("pytest", *session.posargs, TESTS) + session.run("pytest", "--parallel-threads=10", *session.posargs, TESTS) @session() diff --git a/src/lib.rs b/src/lib.rs index 09583f8..c95c40a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1385,7 +1385,7 @@ impl QueuePy { } } -#[pymodule] +#[pymodule(gil_used = false)] #[pyo3(name = "rpds")] fn rpds_py(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; diff --git a/tests/requirements.in b/tests/requirements.in index 1c3a2db..425a283 100644 --- a/tests/requirements.in +++ b/tests/requirements.in @@ -1,2 +1,3 @@ file:.#egg=rpds-py pytest +pytest-run-parallel \ No newline at end of file diff --git a/tests/requirements.txt b/tests/requirements.txt index 325c3ee..0a7421a 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,5 @@ # This file was autogenerated by uv via the following command: -# uv pip compile --output-file /Users/julian/Development/rpds.py/tests/requirements.txt tests/requirements.in +# uv pip compile --output-file tests/requirements.txt tests/requirements.in iniconfig==2.0.0 # via pytest packaging==24.1 @@ -7,6 +7,10 @@ packaging==24.1 pluggy==1.5.0 # via pytest pytest==8.3.3 + # via + # -r tests/requirements.in + # pytest-run-parallel +pytest-run-parallel==0.2.0 # via -r tests/requirements.in file:.#egg=rpds-py # via -r tests/requirements.in From db5c80d37d263bd06457ed76f325f71cb39a1bc4 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Wed, 20 Nov 2024 13:18:43 -0700 Subject: [PATCH 2/4] work around CPython issue 127065 --- tests/test_hash_trie_map.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 9f2d763..3544305 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -30,11 +30,20 @@ from collections import abc from operator import methodcaller import pickle +import sysconfig import pytest from rpds import HashTrieMap +# see https://github.com/python/cpython/issues/127065, +# remove this when the CPython bug is fixed in a released version +if bool(sysconfig.get_config_var("Py_GIL_DISABLED")): + def methodcaller(name, /, *args, **kwargs): + def caller(obj): + return getattr(obj, name)(*args, **kwargs) + return caller + def test_instance_of_hashable(): assert isinstance(HashTrieMap(), abc.Hashable) From 42b39551578e46153b3738f49aa0a9ac089e1656 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Wed, 20 Nov 2024 13:40:58 -0700 Subject: [PATCH 3/4] revert changes to wheel-building config --- .github/workflows/CI.yml | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5a7f65a..895b48c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -80,7 +80,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -88,7 +88,6 @@ jobs: 3.11 3.12 3.13 - 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -96,7 +95,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' sccache: "true" manylinux: auto - name: Upload wheels @@ -118,7 +117,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -126,7 +125,6 @@ jobs: 3.11 3.12 3.13 - 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -134,7 +132,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' manylinux: musllinux_1_2 sccache: "true" - name: Upload wheels @@ -153,7 +151,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -161,7 +159,6 @@ jobs: 3.11 3.12 3.13 - 3.13t ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} allow-prereleases: true @@ -170,7 +167,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -188,7 +185,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -196,7 +193,6 @@ jobs: 3.11 3.12 3.13 - 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -204,7 +200,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -221,7 +217,15 @@ jobs: persist-credentials: false - uses: actions/setup-python@v5 with: - python-version: 3.13 + python-version: | + 3.9 + 3.10 + 3.11 + 3.12 + 3.13 + pypy3.9 + pypy3.10 + allow-prereleases: true - name: Build an sdist uses: PyO3/maturin-action@v1 with: From 76f1cfcfe64a87fa21dfbcce12027c71482adcc1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:43:41 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/requirements.in | 2 +- tests/test_hash_trie_map.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/requirements.in b/tests/requirements.in index 425a283..8dc90bd 100644 --- a/tests/requirements.in +++ b/tests/requirements.in @@ -1,3 +1,3 @@ file:.#egg=rpds-py pytest -pytest-run-parallel \ No newline at end of file +pytest-run-parallel diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 3544305..3dec414 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -39,9 +39,11 @@ # see https://github.com/python/cpython/issues/127065, # remove this when the CPython bug is fixed in a released version if bool(sysconfig.get_config_var("Py_GIL_DISABLED")): + def methodcaller(name, /, *args, **kwargs): def caller(obj): return getattr(obj, name)(*args, **kwargs) + return caller