nixpkgs/pkgs/development/python-modules/pybind11/setup-hook.sh
Ben Wolsieffer 7f8f688ef3 python3Packages.pybind11: fix cross-compilation with setup hook
pybind11's CMake module uses the Python sysconfig module to find the Python
site-packages and include directories. sysconfig returns the wrong values
(from build Python) when cross-compiling, so this patch adds a setup hook to
pass flags to CMake to override the sysconfig results.

Note that the setup hook references build Python, and therefore adds build
Python to pybind11's runtime closure. This is not a problem because pybind11
is a header only library and should never end up as part of another package's
runtime closure.
2023-04-12 15:37:06 -04:00

13 lines
386 B
Bash

# Tell the pybind11 CMake module where to find host platform Python. This is
# required when cross-compiling.
pybind11CMakeFlags () {
cmakeFlagsArray+=(
'-DPYBIND11_PYTHONLIBS_OVERWRITE=OFF'
'-DPYTHON_EXECUTABLE=@pythonInterpreter@'
'-DPYTHON_INCLUDE_DIR=@pythonIncludeDir@'
'-DPYTHON_SITE_PACKAGES=@pythonSitePackages@'
)
}
preConfigureHooks+=(pybind11CMakeFlags)