coincurve icon indicating copy to clipboard operation
coincurve copied to clipboard

Compatibility with free threading Python

Open DimitriPapadopoulos opened this issue 2 months ago • 1 comments

See CI log https://github.com/ofek/coincurve/actions/runs/18650253779/job/53166519349:

  [11/15] /opt/rh/gcc-toolset-14/root/usr/bin/gcc  -pthread -DIS_LINUX -DPy_LIMITED_API -D_libsecp256k1_EXPORTS -I/tmp/tmpmo3kegjv/build/_deps/vendored_library-src/include -isystem /opt/python/cp314-cp314t/include/python3.14t -O3 -DNDEBUG -fPIC -MD -MT cm_python_module/CMakeFiles/_libsecp256k1.dir/__/_gen_c_file/secp256k1_cffi_bindings.c.o -MF cm_python_module/CMakeFiles/_libsecp256k1.dir/__/_gen_c_file/secp256k1_cffi_bindings.c.o.d -o cm_python_module/CMakeFiles/_libsecp256k1.dir/__/_gen_c_file/secp256k1_cffi_bindings.c.o -c /tmp/tmpmo3kegjv/build/_gen_c_file/secp256k1_cffi_bindings.c
  FAILED: [code=1] cm_python_module/CMakeFiles/_libsecp256k1.dir/__/_gen_c_file/secp256k1_cffi_bindings.c.o 
  /opt/rh/gcc-toolset-14/root/usr/bin/gcc  -pthread -DIS_LINUX -DPy_LIMITED_API -D_libsecp256k1_EXPORTS -I/tmp/tmpmo3kegjv/build/_deps/vendored_library-src/include -isystem /opt/python/cp314-cp314t/include/python3.14t -O3 -DNDEBUG -fPIC -MD -MT cm_python_module/CMakeFiles/_libsecp256k1.dir/__/_gen_c_file/secp256k1_cffi_bindings.c.o -MF cm_python_module/CMakeFiles/_libsecp256k1.dir/__/_gen_c_file/secp256k1_cffi_bindings.c.o.d -o cm_python_module/CMakeFiles/_libsecp256k1.dir/__/_gen_c_file/secp256k1_cffi_bindings.c.o -c /tmp/tmpmo3kegjv/build/_gen_c_file/secp256k1_cffi_bindings.c
  In file included from /tmp/tmpmo3kegjv/build/_gen_c_file/secp256k1_cffi_bindings.c:58:
  /opt/python/cp314-cp314t/include/python3.14t/Python.h:51:4: error: #error "The limited API is not currently supported in the free-threaded build"
     51 | #  error "The limited API is not currently supported in the free-threaded build"
        |    ^~~~~
  In file included from /opt/python/cp314-cp314t/include/python3.14t/Python.h:81:
  /opt/python/cp314-cp314t/include/python3.14t/object.h:158:5: error: unknown type name ‘PyMutex’
    158 |     PyMutex ob_mutex;           // per-object lock
        |     ^~~~~~~
  /opt/python/cp314-cp314t/include/python3.14t/object.h: In function ‘Py_SET_SIZE’:
  /opt/python/cp314-cp314t/include/python3.14t/object.h:311:5: error: implicit declaration of function ‘_Py_atomic_store_ssize_relaxed’ [-Wimplicit-function-declaration]
    311 |     _Py_atomic_store_ssize_relaxed(&ob->ob_size, size);
        |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /opt/python/cp314-cp314t/include/python3.14t/Python.h:82:
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h: In function ‘_Py_REFCNT’:
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h:109:26: error: implicit declaration of function ‘_Py_atomic_load_uint32_relaxed’ [-Wimplicit-function-declaration]
    109 |         uint32_t local = _Py_atomic_load_uint32_relaxed(&ob->ob_ref_local);
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h:113:29: error: implicit declaration of function ‘_Py_atomic_load_ssize_relaxed’ [-Wimplicit-function-declaration]
    113 |         Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&ob->ob_ref_shared);
        |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h: In function ‘Py_SET_REFCNT’:
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h:171:9: error: implicit declaration of function ‘_Py_IsOwnedByCurrentThread’ [-Wimplicit-function-declaration]
    171 |     if (_Py_IsOwnedByCurrentThread(ob)) {
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h: In function ‘Py_INCREF’:
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h:274:9: error: implicit declaration of function ‘_Py_atomic_store_uint32_relaxed’ [-Wimplicit-function-declaration]
    274 |         _Py_atomic_store_uint32_relaxed(&op->ob_ref_local, new_local);
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h:277:9: error: implicit declaration of function ‘_Py_atomic_add_ssize’; did you mean ‘__atomic_add_fetch’? [-Wimplicit-function-declaration]
    277 |         _Py_atomic_add_ssize(&op->ob_ref_shared, (1 << _Py_REF_SHARED_SHIFT));
        |         ^~~~~~~~~~~~~~~~~~~~
        |         __atomic_add_fetch
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h: In function ‘Py_DECREF’:
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h:373:13: error: implicit declaration of function ‘_Py_MergeZeroLocalRefcount’ [-Wimplicit-function-declaration]
    373 |             _Py_MergeZeroLocalRefcount(op);
        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
  /opt/python/cp314-cp314t/include/python3.14t/refcount.h:377:9: error: implicit declaration of function ‘_Py_DecRefShared’; did you mean ‘_Py_DecRef’? [-Wimplicit-function-declaration]
    377 |         _Py_DecRefShared(op);
        |         ^~~~~~~~~~~~~~~~
        |         _Py_DecRef

DimitriPapadopoulos avatar Oct 20 '25 11:10 DimitriPapadopoulos

  • Support for free threaded Python requires CFFI v2.0.0.
  • CFFI v2.0.0 does not support CPython 3.13t, only CPython 3.14t.

Added support for free threaded CPython (3.14t+ only). (#178) Note that the free-threaded build does not yet support building extensions with the limited API, so you must set py_limited_api=False when building extensions for the free-threaded build. CPython 3.13t is not currently supported due to differences in sync primitive behavior from 3.14t that result in segfaults.

DimitriPapadopoulos avatar Oct 20 '25 11:10 DimitriPapadopoulos