Skip to content

Unable to install C extension in 3.13t free threaded #856

@angstwad

Description

@angstwad

Python 3.13.3 free threaded version fails to compile the C extensions for pyyaml.

Installing with:

# pip install -v --no-build-isolation pyyaml

You get the following error:

 BUILDING CYTHON EXT; self.include_dirs=['/usr/local/include/python3.13t'] self.library_dirs=['/usr/local/lib'] self.define=None
  building 'yaml._yaml' extension
  creating build/temp.linux-x86_64-cpython-313t/yaml
  gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/usr/local/include/python3.13t -c yaml/_yaml.c -o build/temp.linux-x86_64-cpython-313t/yaml/_yaml.o
  yaml/_yaml.c:2155:80: error: unknown type name ‘__pyx_vectorcallfunc’; did you mean ‘vectorcallfunc’?
   2155 | static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw);
        |                                                                                ^~~~~~~~~~~~~~~~~~~~
        |                                                                                vectorcallfunc
  yaml/_yaml.c:29665:69: error: unknown type name ‘__pyx_vectorcallfunc’; did you mean ‘vectorcallfunc’?
  29665 | static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
        |                                                                     ^~~~~~~~~~~~~~~~~~~~
        |                                                                     vectorcallfunc
  yaml/_yaml.c:29710:80: error: unknown type name ‘__pyx_vectorcallfunc’; did you mean ‘vectorcallfunc’?
  29710 | static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
        |                                                                                ^~~~~~~~~~~~~~~~~~~~
        |                                                                                vectorcallfunc
  yaml/_yaml.c: In function ‘__Pyx_CyFunction_CallAsMethod’:
  yaml/_yaml.c:30399:6: error: unknown type name ‘__pyx_vectorcallfunc’; did you mean ‘vectorcallfunc’?
  30399 |      __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
        |      ^~~~~~~~~~~~~~~~~~~~
        |      vectorcallfunc
  yaml/_yaml.c:2245:45: warning: initialization of ‘int’ from ‘vectorcallfunc’ {aka ‘struct _object * (*)(struct _object *, struct _object * const*, long unsigned int,  struct _object *)’} makes integer from pointer without a cast [-Wint-conversion]
   2245 | #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
        |                                             ^
  yaml/_yaml.c:30399:32: note: in expansion of macro ‘__Pyx_CyFunction_func_vectorcall’
  30399 |      __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
        |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  yaml/_yaml.c:30402:16: warning: implicit declaration of function ‘__Pyx_PyVectorcall_FastCallDict’; did you mean ‘__Pyx_PyObject_FastCallDict’? [-Wimplicit-function-declaration]
  30402 |         return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
        |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        |                __Pyx_PyObject_FastCallDict
  yaml/_yaml.c:30402:16: warning: returning ‘int’ from a function with return type ‘PyObject *’ {aka ‘struct _object *’} makes pointer from integer without a cast [-Wint-conversion]
  30402 |         return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
        |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Error compiling module, falling back to pure Python

Installing the binary version does not include them either:

# pip install -v --no-build-isolation pyyaml --only-binary=wheel
>>> from pyyaml import CSafeLoader
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    from pyyaml import CSafeLoader
ModuleNotFoundError: No module named 'pyyaml'
>>> from yaml import CSafeLoader
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    from yaml import CSafeLoader
ImportError: cannot import name 'CSafeLoader' from 'yaml' (/usr/local/lib/python3.13t/site-packages/yaml/__init__.py). Did you mean: 'SafeLoader'?

Have the following versions installed:

root@ebc84fd57817:/# pip freeze | egrep -ie 'cython|setuptools'
Cython==3.0.12
setuptools==78.1.0

root@ebc84fd57817:/# pip --version
pip 25.0.1 from /usr/local/lib/python3.13t/site-packages/pip (python 3.13)
root@ebc84fd57817:/# python3 --version
Python 3.13.3

root@ebc84fd57817:/# python
Python 3.13.3 experimental free-threading build (main, Apr 15 2025, 18:16:12) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

root@ebc84fd57817:/# apt list | grep libyaml

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libyaml-0-2/now 0.2.5-1 amd64 [installed,local]
libyaml-dev/now 0.2.5-1 amd64 [installed,local]

Using 3.13 standard, this works perfectly from a binary wheel and also compiling from source.

root@3cab962f6856:/# python3
Python 3.13.3 (main, Apr  9 2025, 00:27:54) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from yaml import CSafeLoader
>>> CSafeLoader
<class 'yaml.cyaml.CSafeLoader'>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions