summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/faiss/default.nix
blob: 76bb135148f81a7fc4976c5dbd1baed388a9f6f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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 removeAttrs [ "mainProgram" ])
    (m: m // { description = "Bindings for faiss, the similarity search library"; })
  ];
}