about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkirillrdy <kirillrdy@gmail.com>2024-04-24 19:35:34 +1000
committerGitHub <noreply@github.com>2024-04-24 19:35:34 +1000
commita604d927cd40d6e5f1c9f71c3e1b00613d1a5bc9 (patch)
tree463b45bd13a5194aac1203005866e88b11651f31
parented0e28efccae72a10ae5b49f2d59c05a42453dbf (diff)
parentb556b8b378c6a76d9643287fea28e610ae33bd37 (diff)
Merge pull request #286125 from phiadaarr/nanobind-v1.8.0
python3Packages.nanobind: init at 1.9.0
-rw-r--r--pkgs/development/python-modules/nanobind/default.nix72
-rw-r--r--pkgs/top-level/python-packages.nix2
2 files changed, 74 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/nanobind/default.nix b/pkgs/development/python-modules/nanobind/default.nix
new file mode 100644
index 0000000000000..27460b65a8dba
--- /dev/null
+++ b/pkgs/development/python-modules/nanobind/default.nix
@@ -0,0 +1,72 @@
+{
+  lib,
+  buildPythonPackage,
+  pythonOlder,
+  fetchFromGitHub,
+  cmake,
+  eigen,
+  ninja,
+  scikit-build,
+  pytestCheckHook,
+  numpy,
+  scipy,
+  torch,
+  jax,
+  jaxlib,
+  tensorflow,
+  setuptools,
+}:
+buildPythonPackage rec {
+  pname = "nanobind";
+  version = "1.9.2";
+  pyproject = true;
+
+  src = fetchFromGitHub {
+    owner = "wjakob";
+    repo = pname;
+    rev = "v${version}";
+    hash = "sha256-6swDqw7sEYOawQbNWD8VfSQoi+9wjhOhOOwPPkahDas=";
+    fetchSubmodules = true;
+  };
+
+  disabled = pythonOlder "3.8";
+
+  nativeBuildInputs = [
+    cmake
+    ninja
+    scikit-build
+    setuptools
+  ];
+  buildInputs = [ eigen ];
+  dontUseCmakeBuildDir = true;
+
+  preCheck = ''
+    # build tests
+    make -j $NIX_BUILD_CORES
+  '';
+
+  nativeCheckInputs = [
+    pytestCheckHook
+    numpy
+    scipy
+    torch
+    tensorflow
+    jax
+    jaxlib
+  ];
+
+  meta = with lib; {
+    homepage = "https://github.com/wjakob/nanobind";
+    changelog = "https://github.com/wjakob/nanobind/blob/${src.rev}/docs/changelog.rst";
+    description = "Tiny and efficient C++/Python bindings";
+    longDescription = ''
+      nanobind is a small binding library that exposes C++ types in Python and
+      vice versa. It is reminiscent of Boost.Python and pybind11 and uses
+      near-identical syntax. In contrast to these existing tools, nanobind is
+      more efficient: bindings compile in a shorter amount of time, produce
+      smaller binaries, and have better runtime performance.
+    '';
+    license = licenses.bsd3;
+    maintainers = with maintainers; [ parras ];
+  };
+}
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 19f6b9209cab7..b5d0287f4d5f8 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -8534,6 +8534,8 @@ self: super: with self; {
 
   nampa = callPackage ../development/python-modules/nampa { };
 
+  nanobind = callPackage ../development/python-modules/nanobind { };
+
   nanoid = callPackage ../development/python-modules/nanoid { };
 
   nanoleaf = callPackage ../development/python-modules/nanoleaf { };