From 7c98af33bec55022043f16da7cc3f97947adcf62 Mon Sep 17 00:00:00 2001 From: Emily Date: Wed, 10 Sep 2025 20:32:45 +0100 Subject: [PATCH 1/3] python313Packages.scikit-build-core: fix `cmakeFlags` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was broken when using multiple `cmakeFlags` without `__structuredAttrs`, because `args+=($cmakeFlags)` wouldn’t split it on whitespace. Let’s do something much cleaner instead. --- .../scikit-build-core/append-cmakeFlags.sh | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/pkgs/development/python-modules/scikit-build-core/append-cmakeFlags.sh b/pkgs/development/python-modules/scikit-build-core/append-cmakeFlags.sh index 30b05ff99daf..cdba9eb84d79 100644 --- a/pkgs/development/python-modules/scikit-build-core/append-cmakeFlags.sh +++ b/pkgs/development/python-modules/scikit-build-core/append-cmakeFlags.sh @@ -1,18 +1,9 @@ scikitBuildFlagsHook() { - OLD_IFS="$IFS" - IFS=';' + concatTo flagsArray cmakeFlags cmakeFlagsArray - local args=() - if [[ -n "$SKBUILD_CMAKE_ARGS" ]]; then - read -ra existing_args <<< "$SKBUILD_CMAKE_ARGS" - args+=("${existing_args[@]}") - fi - args+=($cmakeFlags) - args+=("${cmakeFlagsArray[@]}") - export SKBUILD_CMAKE_ARGS="${args[*]}" - - IFS="$OLD_IFS" - unset OLD_IFS + for arg in "${flagsArray[@]}"; do + appendToVar pypaBuildFlags "-Ccmake.args=$arg" + done } preConfigureHooks+=(scikitBuildFlagsHook) From 6fe4137aacaf8dc7185d9cdfbc0de2b0008c3982 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Mon, 23 Jun 2025 12:33:58 +0300 Subject: [PATCH 2/3] python313Packages.pybind11: no with lib; in meta --- pkgs/development/python-modules/pybind11/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/pybind11/default.nix b/pkgs/development/python-modules/pybind11/default.nix index 2dfe5bfe805d..e7f4b9055db4 100644 --- a/pkgs/development/python-modules/pybind11/default.nix +++ b/pkgs/development/python-modules/pybind11/default.nix @@ -106,7 +106,7 @@ buildPythonPackage rec { hardeningDisable = lib.optional stdenv.hostPlatform.isMusl "fortify"; - meta = with lib; { + meta = { homepage = "https://github.com/pybind/pybind11"; changelog = "https://github.com/pybind/pybind11/blob/${src.rev}/docs/changelog.rst"; description = "Seamless operability between C++11 and Python"; @@ -116,8 +116,8 @@ buildPythonPackage rec { C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. ''; - license = licenses.bsd3; - maintainers = with maintainers; [ + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ yuriaisaka dotlambda ]; From 9d8e2cb75f69d5185addd49294ff101c2d57d33e Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 12 Sep 2025 01:20:06 +0100 Subject: [PATCH 3/3] 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";