1{
2 buildPythonPackage,
3 fetchFromGitHub,
4 lib,
5 libjpeg,
6 numba,
7 opencv4,
8 pandas,
9 pkg-config,
10 pytorch-pfn-extras,
11 terminaltables,
12 tqdm,
13}:
14
15buildPythonPackage rec {
16 pname = "ffcv";
17 version = "1.0.0";
18 format = "setuptools";
19
20 src = fetchFromGitHub {
21 owner = "libffcv";
22 repo = pname;
23 rev = "refs/tags/v${version}";
24 hash = "sha256-L2mwGFivq/gtAw+1D6U2jbW6VxYgetHX7OUrjwyybqE=";
25 };
26
27 # See https://github.com/libffcv/ffcv/issues/159.
28 postPatch = ''
29 substituteInPlace setup.py \
30 --replace "'assertpy'," "" \
31 --replace "'fastargs'," "" \
32 --replace "'imgcat'," "" \
33 --replace "'matplotlib'," "" \
34 --replace "'psutil'," "" \
35 --replace "'sklearn'," "" \
36 --replace "'webdataset'," ""
37 '';
38
39 nativeBuildInputs = [ pkg-config ];
40 buildInputs = [ libjpeg ];
41 propagatedBuildInputs = [
42 opencv4
43 numba
44 pandas
45 pytorch-pfn-extras
46 terminaltables
47 tqdm
48 ];
49
50 # `ffcv._libffcv*.so` cannot be loaded in the nix build environment for some
51 # reason. See https://github.com/NixOS/nixpkgs/pull/160441#issuecomment-1045204722.
52 doCheck = false;
53
54 pythonImportsCheck = [ "ffcv" ];
55
56 meta = with lib; {
57 description = "FFCV: Fast Forward Computer Vision";
58 homepage = "https://ffcv.io";
59 license = licenses.asl20;
60 maintainers = with maintainers; [ samuela ];
61 };
62}