From 9d8e2cb75f69d5185addd49294ff101c2d57d33e Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 12 Sep 2025 01:20:06 +0100 Subject: [PATCH] python313Packages.pybind11: 2.13.6 -> 3.0.1 Diff: https://github.com/pybind/pybind11/compare/refs/tags/v2.13.6...refs/tags/v3.0.1 Changelog: https://github.com/pybind/pybind11/blob/refs/tags/v3.0.1/docs/changelog.rst Co-authored-by: Doron Behar --- .../python-modules/pybind11/default.nix | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/pkgs/development/python-modules/pybind11/default.nix b/pkgs/development/python-modules/pybind11/default.nix index e7f4b9055db4..4ce742c363ff 100644 --- a/pkgs/development/python-modules/pybind11/default.nix +++ b/pkgs/development/python-modules/pybind11/default.nix @@ -6,13 +6,14 @@ fetchFromGitHub, cmake, ninja, - setuptools, + scikit-build-core, + pybind11, boost, eigen, python, catch2, numpy, - pytestCheckHook, + pytest, libxcrypt, makeSetupHook, }: @@ -29,80 +30,79 @@ let in buildPythonPackage rec { pname = "pybind11"; - version = "2.13.6"; + version = "3.0.1"; pyproject = true; src = fetchFromGitHub { owner = "pybind"; repo = "pybind11"; tag = "v${version}"; - hash = "sha256-SNLdtrOjaC3lGHN9MAqTf51U9EzNKQLyTMNPe0GcdrU="; + hash = "sha256-ZiwNGsE1FOkhnWv/1ib1akhQ4FZvrXRCDnnBZoPp6r4="; }; build-system = [ cmake ninja - setuptools + pybind11.passthru.scikit-build-core-no-tests + ]; + + buildInputs = [ + # Used only for building tests - something we do even when cross + # compiling. + catch2 + boost + eigen ]; - buildInputs = lib.optionals (pythonOlder "3.9") [ libxcrypt ]; propagatedNativeBuildInputs = [ setupHook ]; - dontUseCmakeBuildDir = true; + nativeCheckInputs = [ + numpy + pytest + ]; - # Don't build tests if not needed, read the doInstallCheck value at runtime - preConfigure = '' - if [ -n "$doInstallCheck" ]; then - cmakeFlagsArray+=("-DBUILD_TESTING=ON") - fi - ''; + pypaBuildFlags = [ + # Keep the build directory around to run the tests. + "-Cbuild-dir=build" + ]; cmakeFlags = [ - "-DBoost_INCLUDE_DIR=${lib.getDev boost}/include" - "-DCATCH_INCLUDE_DIR=${lib.getDev catch2}/include/catch2" - "-DEIGEN3_INCLUDE_DIR=${lib.getDev eigen}/include/eigen3" - ] - ++ lib.optionals (python.isPy3k && !stdenv.cc.isClang) [ "-DPYBIND11_CXX_STANDARD=-std=c++17" ]; + # Always build tests, because even when cross compiling building the tests + # is another confirmation that everything is OK. + (lib.cmakeBool "BUILD_TESTING" true) - postBuild = '' - # build tests - make -j $NIX_BUILD_CORES - ''; + # Override the `PYBIND11_NOPYTHON = true` in `pyproject.toml`. This + # is required to build the tests. + (lib.cmakeBool "PYBIND11_NOPYTHON" false) + ]; + dontUseCmakeConfigure = true; + + ninjaFlags = [ + "-C" + "build" + ]; + + checkTarget = "check"; + + checkPhase = "ninjaCheckPhase"; + + # Make the headers and CMake/pkg-config files inside the wheel + # discoverable. This simulates the effect of the `pybind11[global]` + # installation but works better for our build. postInstall = '' - make install - # Symlink the CMake-installed headers to the location expected by setuptools - mkdir -p $out/include/${python.libPrefix} - ln -sf $out/include/pybind11 $out/include/${python.libPrefix}/pybind11 + ln -s $out/${python.sitePackages}/pybind11/{include,share} $out/ ''; - nativeCheckInputs = [ - catch2 - numpy - pytestCheckHook - ]; - - disabledTestPaths = [ - # require dependencies not available in nixpkgs - "tests/test_embed/test_trampoline.py" - "tests/test_embed/test_interpreter.py" - # numpy changed __repr__ output of numpy dtypes - "tests/test_numpy_dtypes.py" - # no need to test internal packaging - "tests/extra_python_package/test_files.py" - # tests that try to parse setuptools stdout - "tests/extra_setuptools/test_setuphelper.py" - ]; - - disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [ - # expects KeyError, gets RuntimeError - # https://github.com/pybind/pybind11/issues/4243 - "test_cross_module_exception_translator" - ]; - - postCheck = '' - make cpptest - ''; + passthru = { + # scikit-build-core's tests depend upon pybind11, and hence introduce + # infinite recursion. To avoid this, we define here a scikit-build-core + # derivation that doesn't depend on pybind11, and use it for pybind11's + # build-system. + scikit-build-core-no-tests = scikit-build-core.overridePythonAttrs { + doCheck = false; + }; + }; hardeningDisable = lib.optional stdenv.hostPlatform.isMusl "fortify";