cffi: derive Python include dir from PYO3_CROSS_LIB_DIR when cross-compiling (#14904)
When cross-compiling, ``cryptography-cffi/build.rs`` queries the host
interpreter via ``setuptools.command.build_ext.build_ext.include_dirs``
and feeds the result into ``cc-rs`` as ``-I /usr/include/python3.X``.
On hosts that happen to ship Python development headers for the same
3.X line as the target (e.g. an Arch Linux build host with Python 3.14
installed), the host headers leak into the cross build and the target
compiler aborts with::
/usr/include/python3.14/pyport.h:429:2: error: #error "LONG_BIT
definition appears wrong for platform (bad gcc/glibc config?)."
``PYO3_CROSS_LIB_DIR`` is the documented PyO3 cross-compile signal and
points at the target's libpython directory. When it is set, derive the
matching Python include dir from it (``<prefix>/include/<py_ver>``) and
skip the host setuptools probe entirely. Native builds keep the
existing setuptools-based behaviour, so this is a no-op outside of
PyO3-style cross builds.
This is consistent with the existing ``PYO3_PYTHON`` handling in the
same file: cryptography-cffi already respects PyO3's cross-compile
environment for picking the interpreter, and this extends that to the
matching header directory.
Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>2 files changed