about summary refs log tree commit diff
path: root/pkgs/development/python-modules/ffcv/default.nix
blob: 05750d9baed31df8e76ae274e7fe0ac7a4f1d8e1 (plain) (blame)
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
54
55
56
57
58
59
60
61
62
{
  buildPythonPackage,
  fetchFromGitHub,
  lib,
  libjpeg,
  numba,
  opencv4,
  pandas,
  pkg-config,
  pytorch-pfn-extras,
  terminaltables,
  tqdm,
}:

buildPythonPackage rec {
  pname = "ffcv";
  version = "1.0.0";
  format = "setuptools";

  src = fetchFromGitHub {
    owner = "libffcv";
    repo = pname;
    rev = "refs/tags/v${version}";
    hash = "sha256-L2mwGFivq/gtAw+1D6U2jbW6VxYgetHX7OUrjwyybqE=";
  };

  # See https://github.com/libffcv/ffcv/issues/159.
  postPatch = ''
    substituteInPlace setup.py \
      --replace "'assertpy'," "" \
      --replace "'fastargs'," "" \
      --replace "'imgcat'," "" \
      --replace "'matplotlib'," "" \
      --replace "'psutil'," "" \
      --replace "'sklearn'," "" \
      --replace "'webdataset'," ""
  '';

  nativeBuildInputs = [ pkg-config ];
  buildInputs = [ libjpeg ];
  propagatedBuildInputs = [
    opencv4
    numba
    pandas
    pytorch-pfn-extras
    terminaltables
    tqdm
  ];

  # `ffcv._libffcv*.so` cannot be loaded in the nix build environment for some
  # reason. See https://github.com/NixOS/nixpkgs/pull/160441#issuecomment-1045204722.
  doCheck = false;

  pythonImportsCheck = [ "ffcv" ];

  meta = with lib; {
    description = "FFCV: Fast Forward Computer Vision";
    homepage = "https://ffcv.io";
    license = licenses.asl20;
    maintainers = with maintainers; [ samuela ];
  };
}