Bug 2245819 - python-cffi fails to build with Python 3.13: Missing <ctype.h>, implicit declaration of function '_PyThreadState_UncheckedGet', '_PyUnicode_AsString', '_PyLong_Sign', '_Py_HashPointer', '_PyErr_WriteUnraisable'
Summary: python-cffi fails to build with Python 3.13: Missing <ctype.h>, implicit decl...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-cffi
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2023-10-24 08:29 UTC by Karolina Surma
Modified: 2023-11-29 13:13 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2023-11-29 13:13:40 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources python-cffi pull-request 23 0 None None None 2023-11-19 16:27:46 UTC
Github python-cffi cffi issues 23 0 None open cffi fails to build on Python 3.13 2023-10-24 10:17:32 UTC
Github python-cffi cffi pull 24 0 None Draft [WIP] Python 3.13 compatibility 2023-10-24 10:17:32 UTC
Github python-cffi cffi pull 34 0 None Merged Use PyErr_FormatUnraisable() on Python 3.13 2023-11-19 16:27:46 UTC

Description Karolina Surma 2023-10-24 08:29:44 UTC
python-cffi fails to build with Python 3.13.0a1.

src/c/misc_thread_common.h:335:12: error: implicit declaration of function _PyThreadState_UncheckedGet; did you mean PyThreadState_GetUnchecked? [-Werror=implicit-function-declaration]
    335 |     return _PyThreadState_UncheckedGet();
        |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
        |            PyThreadState_GetUnchecked

  src/c/_cffi_backend.c:137:24: error: implicit declaration of function _PyUnicode_AsString; did you mean PyUnicode_Substring? [-Werror=implicit-function-declaration]
    137 | # define PyText_AsUTF8 _PyUnicode_AsString   /* PyUnicode_AsUTF8 in Py3.3 */
        |                        ^~~~~~~~~~~~~~~~~~~
  src/c/_cffi_backend.c:868:17: error: implicit declaration of function _PyLong_Sign [-Werror=implicit-function-declaration]
    868 |             if (_PyLong_Sign(ob) < 0)
        |                 ^~~~~~~~~~~~
  src/c/_cffi_backend.c:2449:12: error: implicit declaration of function _Py_HashPointer [-Werror=implicit-function-declaration]
   2449 |     return _Py_HashPointer(((CDataObject *)v)->c_data);
        |            ^~~~~~~~~~~~~~~
  src/c/_cffi_backend.c:6121:9: error: implicit declaration of function _PyErr_WriteUnraisable; did you mean PyErr_WriteUnraisable? [-Werror=implicit-function-declaration]
   6121 |         _PyErr_WriteUnraisableMsg(PyText_AS_UTF8(s), NULL);
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~
        |         PyErr_WriteUnraisable

According to https://docs.python.org/3.13/whatsnew/3.13.html:

- Python.h no longer includes the <ctype.h> standard header file.
If needed, it should now be included explicitly.
For example, it provides isalpha() and tolower() functions which are locale dependent.
Python provides locale independent functions, like Py_ISALPHA() and Py_TOLOWER().
(Contributed by Victor Stinner in gh-108765.)
- There have been many changes to the C API, see details in: https://docs.python.org/3.13/whatsnew/3.13.html
- The detailed list of the removed private C API functions can be found here: https://github.com/python/cpython/issues/106320

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06551047-python-cffi/

For all our attempts to build python-cffi with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-cffi/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Miro Hrončok 2023-10-24 10:17:33 UTC
https://github.com/python-cffi/cffi/issues/23
https://github.com/python-cffi/cffi/pull/24

The WIP upstream fix still does not work with -Werror=implicit-function-declaration but nevertheless the tests pass.

I'll hack that up in the @python/python3.13 copr to unblock things. Hopefully, we'll get a better fix later.

Comment 2 Miro Hrončok 2023-10-24 10:36:44 UTC
Building the package in Copr with:


Patch:          https://github.com/python-cffi/cffi/pull/24.patch
%global build_type_safety_c 0

Comment 3 Miro Hrončok 2023-11-19 16:27:46 UTC
Witch recent changes in Python 3.13, https://github.com/python-cffi/cffi/pull/34 should be enough: https://src.fedoraproject.org/rpms/python-cffi/pull-request/23


Note You need to log in before you can comment on or make changes to this bug.