From e21b41e36e772bf52199aa456535f5c2975b94f7 Mon Sep 17 00:00:00 2001 From: Florian Agbuya Date: Thu, 8 Jan 2026 14:47:43 +0800 Subject: [PATCH] python313Packages.pybind11: fix cross-compilation when CPU bit depth differs --- .../development/python-modules/pybind11/default.nix | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkgs/development/python-modules/pybind11/default.nix b/pkgs/development/python-modules/pybind11/default.nix index 4b49b52abe82..c4505f01ea50 100644 --- a/pkgs/development/python-modules/pybind11/default.nix +++ b/pkgs/development/python-modules/pybind11/default.nix @@ -14,6 +14,9 @@ numpy, pytest, makeSetupHook, + # Build tests to verify cross-compilation works, but only when CPU bit + # depth matches (otherwise Python headers cause LONG_BIT mismatch errors) + buildTests ? stdenv.hostPlatform.parsed.cpu.bits == stdenv.buildPlatform.parsed.cpu.bits, }: let setupHook = makeSetupHook { @@ -44,9 +47,7 @@ buildPythonPackage rec { pybind11.passthru.scikit-build-core-no-tests ]; - buildInputs = [ - # Used only for building tests - something we do even when cross - # compiling. + buildInputs = lib.optionals buildTests [ catch2 boost eigen @@ -65,13 +66,11 @@ buildPythonPackage rec { ]; cmakeFlags = [ - # Always build tests, because even when cross compiling building the tests - # is another confirmation that everything is OK. - (lib.cmakeBool "BUILD_TESTING" true) + (lib.cmakeBool "BUILD_TESTING" buildTests) # Override the `PYBIND11_NOPYTHON = true` in `pyproject.toml`. This # is required to build the tests. - (lib.cmakeBool "PYBIND11_NOPYTHON" false) + (lib.cmakeBool "PYBIND11_NOPYTHON" (!buildTests)) ]; dontUseCmakeConfigure = true;