You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
setup.py grep_headers_for() is broken by design #89761
The setup.py helper function grep_headers_for() is used by ctypes build step to search header files for functions. The function kinda works on most platforms, but only by accident. On my system it opens all header files that match /usr/include/*.h and returns true if any (!) header file contains the string (!) "ffi_prep_cif_var". The check would also match "ffi_prep_cif_var" in a comment of an unrelated header file.
We cannot limit the search to "ffi.h" only, because that would break multiarch builds with a header file like this:
Use "AC_EGREP_HEADER" autoconf macro. It runs a header file through the C preprocessor
Use AC_LINK_IFELSE autoconf macro. This macro compiles and links code to detect if a library exports a function.
Re-implement any of the macros in pure Python (ugh!)
Just assume that libffi supports ffi_prep_cif_var, ffi_prep_closure_loc, and ffi_closure_alloc on our target platforms. According to [1] the functions have been around for over a decade.
I favor (4).
Ned, what about USING_APPLE_OS_LIBFFI? Is it still relevant?
Activity
tiran commentedon Oct 24, 2021
The setup.py helper function grep_headers_for() is used by ctypes build step to search header files for functions. The function kinda works on most platforms, but only by accident. On my system it opens all header files that match /usr/include/*.h and returns true if any (!) header file contains the string (!) "ffi_prep_cif_var". The check would also match "ffi_prep_cif_var" in a comment of an unrelated header file.
We cannot limit the search to "ffi.h" only, because that would break multiarch builds with a header file like this:
Solutions:
I favor (4).
Ned, what about USING_APPLE_OS_LIBFFI? Is it still relevant?
[1] https://github.com/libffi/libffi/blame/48bdb02867edb7e9f3785ccb4bdff1087fb44246/include/ffi.h.in#L309
tiran commentedon Oct 24, 2021
If we remove grep_headers_for(), then we can also close bpo-42325
merwok commentedon Oct 30, 2021
We could look in distro patch trackers to see they patch CPython’s setup.py to evaluate the impact of removing this function.
ned-deily commentedon Nov 3, 2021
It was just added a year ago as part of the support for macOS 11 Big Sur and Apple Silicon systems.
kumaraditya303 commentedon Jul 23, 2022
Closing as
setup.pyis now removed, feel free to reopen if required.kumaraditya303 commentedon Jul 24, 2022
Removed 3.9 as it is in security fixes only and this is not a security issue.
arhadthedev commentedon Apr 29, 2023
Same for 3.10.
erlend-aasland commentedon Jun 19, 2023
setup.py does not exist in
main, 3.12, or 3.11; older branches only receive security fixes. Closing as out-of-date.