Cannot include Python.h in 3.12 without linking against the CPython library #108502
Open
2 tasks done
Labels
type-bug
An unexpected behavior, bug, or error
Bug report
Checklist
and am confident this bug has not been reported before
CPython versions tested on:
3.12
Operating systems tested on:
macOS
Output from running 'python -VV' on the command line:
Python 3.12.0rc1+ (heads/3.12:ce37fbc778, Aug 25 2023, 16:39:06) [Clang 14.0.3 (clang-1403.0.22.14.1)]
A clear and concise description of the bug:
I have been trying to diagnose some issues with Vim's compilation issues (vim/vim#12660) with its Python interface and it appears 3.12 has introduced a dependency to linkage in its header.
The way Vim dynamic Python binding works is it loads the Python DLL/dylib/so library at runtime to allows the user to provide their own Python installation. When built this way, we only compile the Python interface code, but we don't need to explicitly link against the Python library because we are just using
dlopen()
to load the library and necessary functions.When compiling this way with Python 3.12, we see this error:
The issue comes from commit 7559f5f, which added the asserts which now reference
PyLong_Type
, so if you just include the header and callPy_Size()
, it will now need to link against the Python lib to find the missingPyLong_Type
andPyBool_Type
:I'm filing this as a bug because it used to be the case that you could compile against Python without requiring linking against the library at build time. This seems to change the requirement.
Note that this is only the case if limited API is not used.
The text was updated successfully, but these errors were encountered: