about summary refs log tree commit diff
path: root/pkgs/development/python-modules/faiss/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/faiss/default.nix')
-rw-r--r--pkgs/development/python-modules/faiss/default.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/faiss/default.nix b/pkgs/development/python-modules/faiss/default.nix
new file mode 100644
index 000000000000..39e34a1879e8
--- /dev/null
+++ b/pkgs/development/python-modules/faiss/default.nix
@@ -0,0 +1,53 @@
+{
+  lib,
+  buildPythonPackage,
+  callPackage,
+  faiss-build,
+  numpy,
+  packaging,
+  setuptools,
+  pip,
+}:
+
+buildPythonPackage {
+  inherit (faiss-build) pname version;
+  pyproject = true;
+
+  src = "${lib.getOutput "dist" faiss-build}";
+
+  postPatch = ''
+    mkdir dist
+    mv *.whl dist/
+  '';
+
+  build-system = [
+    setuptools
+    pip
+  ];
+
+  dependencies = [
+    numpy
+    packaging
+  ];
+
+  # E.g. cuda libraries; needed because reference scanning
+  # can't see inside the wheels
+  inherit (faiss-build) buildInputs;
+
+  dontBuild = true;
+
+  pythonImportsCheck = [ "faiss" ];
+
+  passthru = {
+    inherit (faiss-build) cudaSupport cudaPackages pythonSupport;
+
+    tests = {
+      pytest = callPackage ./pytest.nix { inherit faiss-build; };
+    };
+  };
+
+  meta = lib.pipe (faiss-build.meta or { }) [
+    (lib.flip builtins.removeAttrs [ "mainProgram" ])
+    (m: m // { description = "Bindings for faiss, the similarity search library"; })
+  ];
+}