Skip to content

Support the Python 3.14t free-threaded build #467

@ngoldbaum

Description

@ngoldbaum

CFFI 2.0.0b1 added support for Python 3.14 and the new free-threaded build and NumPy 2.3.2 has cp314t wheels. If I use CFFI 2.0.0b1 I'm able to build python-soundfile and run the tests successfully:

goldbaum at Nathans-MBP in ~/Documents/python-soundfile on master
(.env) ± pip install --pre cffi
Collecting cffi
  Using cached cffi-2.0.0b1-cp314-cp314t-macosx_11_0_arm64.whl.metadata (2.5 kB)
Collecting pycparser (from cffi)
  Using cached pycparser-2.22-py3-none-any.whl.metadata (943 bytes)
Using cached cffi-2.0.0b1-cp314-cp314t-macosx_11_0_arm64.whl (185 kB)
Using cached pycparser-2.22-py3-none-any.whl (117 kB)
Installing collected packages: pycparser, cffi
Successfully installed cffi-2.0.0b1 pycparser-2.22
(.env)
goldbaum at Nathans-MBP in ~/Documents/python-soundfile on master
(.env) ± python -m pip install .
Processing /Users/goldbaum/Documents/python-soundfile
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: cffi>=1.0 in ./.env/lib/python3.14t/site-packages (from soundfile==0.13.1) (2.0.0b1)
Collecting numpy (from soundfile==0.13.1)
  Downloading numpy-2.3.2-cp314-cp314t-macosx_14_0_arm64.whl.metadata (62 kB)
Collecting typing-extensions (from soundfile==0.13.1)
  Using cached typing_extensions-4.14.1-py3-none-any.whl.metadata (3.0 kB)
Requirement already satisfied: pycparser in ./.env/lib/python3.14t/site-packages (from cffi>=1.0->soundfile==0.13.1) (2.22)
Downloading numpy-2.3.2-cp314-cp314t-macosx_14_0_arm64.whl (5.2 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.2/5.2 MB 11.4 MB/s eta 0:00:00
Using cached typing_extensions-4.14.1-py3-none-any.whl (43 kB)
Building wheels for collected packages: soundfile
  Building wheel for soundfile (pyproject.toml) ... done
  Created wheel for soundfile: filename=soundfile-0.13.1-py2.py3-none-macosx_11_0_arm64.whl size=26221 sha256=4962fcf825b82025e3c0d5b9f69e55b491a35c9d90d4f0c84450dcd8aca66b15
  Stored in directory: /Users/goldbaum/Library/Caches/pip/wheels/9e/32/24/ae395221f547427c7375f3969bc9d4b30d91a038d18c6dea5e
Successfully built soundfile
Installing collected packages: typing-extensions, numpy, soundfile
Successfully installed numpy-2.3.2 soundfile-0.13.1 typing-extensions-4.14.1
(.env)
goldbaum at Nathans-MBP in ~/Documents/python-soundfile on master
(.env) ± pip install pytest
Collecting pytest
  Using cached pytest-8.4.1-py3-none-any.whl.metadata (7.7 kB)
Collecting iniconfig>=1 (from pytest)
  Using cached iniconfig-2.1.0-py3-none-any.whl.metadata (2.7 kB)
Collecting packaging>=20 (from pytest)
  Using cached packaging-25.0-py3-none-any.whl.metadata (3.3 kB)
Collecting pluggy<2,>=1.5 (from pytest)
  Using cached pluggy-1.6.0-py3-none-any.whl.metadata (4.8 kB)
Collecting pygments>=2.7.2 (from pytest)
  Using cached pygments-2.19.2-py3-none-any.whl.metadata (2.5 kB)
Using cached pytest-8.4.1-py3-none-any.whl (365 kB)
Using cached pluggy-1.6.0-py3-none-any.whl (20 kB)
Using cached iniconfig-2.1.0-py3-none-any.whl (6.0 kB)
Using cached packaging-25.0-py3-none-any.whl (66 kB)
Using cached pygments-2.19.2-py3-none-any.whl (1.2 MB)
Installing collected packages: pygments, pluggy, packaging, iniconfig, pytest
Successfully installed iniconfig-2.1.0 packaging-25.0 pluggy-1.6.0 pygments-2.19.2 pytest-8.4.1
(.env)
goldbaum at Nathans-MBP in ~/Documents/python-soundfile on master
(.env) ± pytest
============================= test session starts ==============================
platform darwin -- Python 3.14.0rc1, pytest-7.4.0, pluggy-1.6.0
codspeed: 4.0.0 (disabled, mode: walltime, callgraph: not supported, timer_resolution: 41.7ns)
rootdir: /Users/goldbaum/Documents/python-soundfile
plugins: anyio-4.9.0, run-parallel-0.5.0, xdist-3.8.0, codspeed-4.0.0, timeout-2.4.0, cov-4.1.0, mock-3.14.1, hypothesis-6.104.1
collected 331 items
Collected 0 items to run in parallel

tests/test_argspec.py ....                                               [  1%]
tests/test_soundfile.py ................................................ [ 15%]
........................................................................ [ 37%]
........................................................................ [ 59%]
........................................................................ [ 80%]
...............................................................          [100%]

=============================== warnings summary ===============================
tests/test_soundfile.py::test_garbage[name]
  /Users/goldbaum/.pyenv/versions/3.14.0rc1t/lib/python3.14t/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning: Exception ignored from cffi callback <function SoundFile._init_virtual_io.<locals>.vio_write at 0x583ce2bc540>: None

  Traceback (most recent call last):
    File "/Users/goldbaum/.pyenv/versions/3.14.0rc1t/lib/python3.14t/site-packages/soundfile.py", line 1340, in vio_write
      written = file.write(data)
  ValueError: I/O operation on closed file

    warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================== 331 passed, 1 warning in 0.37s ========================

FWIW I also see the warning reported at the end using the GIL enabled build.

Would the maintainers be open to uploading cp314t wheels? Or would you like to do more multithreaded stress testing first? I don't see any existing tests using the threading module or ThreadPoolExecutor so there's probably not much or any existing test coverage for multithreaded scenarios. However IMO that shouldn't block uploading free-threaded wheels since any thread safety issues are also likely present on the GIL-enabled build too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions