1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 cmake, 9 ninja, 10 pathspec, 11 scikit-build-core, 12 13 # dependencies 14 eigen, 15 16 # tests 17 pytestCheckHook, 18 numpy, 19 scipy, 20 torch, 21 tensorflow-bin, 22 jax, 23 jaxlib, 24 25 nanobind, 26}: 27buildPythonPackage rec { 28 pname = "nanobind"; 29 version = "2.7.0"; 30 pyproject = true; 31 32 src = fetchFromGitHub { 33 owner = "wjakob"; 34 repo = "nanobind"; 35 tag = "v${version}"; 36 fetchSubmodules = true; 37 hash = "sha256-ex5svqDp9XJtiNCxu0249ORL6LbG679U6PvKQaWANmE="; 38 }; 39 40 build-system = [ 41 cmake 42 ninja 43 pathspec 44 scikit-build-core 45 ]; 46 47 dependencies = [ eigen ]; 48 49 dontUseCmakeBuildDir = true; 50 51 # nanobind check requires heavy dependencies such as tensorflow 52 # which are less than ideal to be imported in children packages that 53 # use it as build-system parameter. 54 doCheck = false; 55 56 preCheck = '' 57 # build tests 58 make -j $NIX_BUILD_CORES 59 ''; 60 61 nativeCheckInputs = 62 [ 63 pytestCheckHook 64 numpy 65 scipy 66 torch 67 ] 68 ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform tensorflow-bin) [ 69 tensorflow-bin 70 jax 71 jaxlib 72 ]; 73 74 passthru.tests = { 75 pytest = nanobind.overridePythonAttrs { doCheck = true; }; 76 }; 77 78 meta = { 79 homepage = "https://github.com/wjakob/nanobind"; 80 changelog = "https://github.com/wjakob/nanobind/blob/${src.tag}/docs/changelog.rst"; 81 description = "Tiny and efficient C++/Python bindings"; 82 longDescription = '' 83 nanobind is a small binding library that exposes C++ types in Python and 84 vice versa. It is reminiscent of Boost.Python and pybind11 and uses 85 near-identical syntax. In contrast to these existing tools, nanobind is 86 more efficient: bindings compile in a shorter amount of time, produce 87 smaller binaries, and have better runtime performance. 88 ''; 89 license = lib.licenses.bsd3; 90 maintainers = with lib.maintainers; [ parras ]; 91 }; 92}