Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions pkgs/development/python-modules/pybind11/3_0.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
stdenv,
lib,
buildPythonPackage,
fetchFromGitHub,
cmake,
ninja,
scikit-build-core,
boost,
eigen,
python,
catch2,
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 {
name = "pybind11-setup-hook";
substitutions = {
pythonInterpreter = python.pythonOnBuildForHost.interpreter;
pythonIncludeDir = "${python}/include/${python.libPrefix}";
pythonSitePackages = "${python}/${python.sitePackages}";
};
meta.license = lib.licenses.mit;
} ./setup-hook.sh;
in
buildPythonPackage (finalAttrs: {
pname = "pybind11";
version = "3.0.4";
pyproject = true;

src = fetchFromGitHub {
owner = "pybind";
repo = "pybind11";
tag = "v${finalAttrs.version}";
hash = "sha256-QZKnIOopEDsiRFkc1qQ+DaDHoTNuEEgQVeiAL0sQqak=";
};

build-system = [
cmake
ninja
finalAttrs.passthru.scikit-build-core-no-tests
];

buildInputs = lib.optionals buildTests [
catch2
boost
eigen
];

propagatedNativeBuildInputs = [ setupHook ];

nativeCheckInputs = [
numpy
pytest
];

pypaBuildFlags = [
# Keep the build directory around to run the tests.
"-Cbuild-dir=build"
];

cmakeFlags = [
(lib.cmakeBool "BUILD_TESTING" buildTests)

# Override the `PYBIND11_NOPYTHON = true` in `pyproject.toml`. This
# is required to build the tests.
(lib.cmakeBool "PYBIND11_NOPYTHON" (!buildTests))
];

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 = ''
ln -s $out/${python.sitePackages}/pybind11/{include,share} $out/
'';

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";

meta = {
homepage = "https://github.com/pybind/pybind11";
changelog = "https://github.com/pybind/pybind11/blob/${finalAttrs.src.tag}/docs/changelog.md";
description = "Seamless operability between C++11 and Python";
mainProgram = "pybind11-config";
longDescription = ''
Pybind11 is a lightweight header-only library that exposes
C++ types in Python and vice versa, mainly to create Python
bindings of existing C++ code.
'';
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [
yuriaisaka
dotlambda
];
};
})
14 changes: 3 additions & 11 deletions pkgs/development/python-modules/scipp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
boost,
eigen,
gtest,
pybind11,
pybind11_3_0,
onetbb,

# tests
Expand All @@ -36,15 +36,6 @@
hypothesis,
}:

let
# https://github.com/scipp/scipp/blob/v26.9.0/pyproject.toml#L7-L10
pybind11' = pybind11.overridePythonAttrs (old: {
version = "3.0.4";
src = old.src.override {
hash = "sha256-QZKnIOopEDsiRFkc1qQ+DaDHoTNuEEgQVeiAL0sQqak=";
};
});
in
buildPythonPackage (finalAttrs: {
pname = "scipp";
version = "26.9.0";
Expand Down Expand Up @@ -82,7 +73,8 @@ buildPythonPackage (finalAttrs: {
boost
eigen
gtest
pybind11'
# https://github.com/scipp/scipp/blob/v26.9.0/pyproject.toml#L7-L10
pybind11_3_0
units-llnl.passthru.top-level
onetbb
];
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14655,6 +14655,8 @@ self: super: with self; {

pybind11-stubgen = callPackage ../development/python-modules/pybind11-stubgen { };

pybind11_3_0 = callPackage ../development/python-modules/pybind11/3_0.nix { };

pybindgen = callPackage ../development/python-modules/pybindgen { };

pyblackbird = callPackage ../development/python-modules/pyblackbird { };
Expand Down
Loading