about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/compressai/default.nix
blob: 47487a6f633f47045e7358ea5fb710d4c4f4eb1e (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{ lib
, buildPythonPackage
, pythonOlder
, fetchFromGitHub
, pybind11
, setuptools
, wheel
, numpy
, matplotlib
, pytorch-msssim
, scipy
, torch
, torchvision
, ipywidgets
, jupyter
, plotly
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "compressai";
  version = "1.2.4";
  pyproject = true;

  disabled = pythonOlder "3.6";

  src = fetchFromGitHub {
    owner = "InterDigitalInc";
    repo = "CompressAI";
    rev = "refs/tags/v${version}";
    hash = "sha256-nT2vd7t67agIWobJalORbRuns0UJGRGGbTX2/8vbTiY=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    pybind11
    setuptools
    wheel
  ];

  propagatedBuildInputs = [
    numpy
    matplotlib
    pytorch-msssim
    scipy
    torch
    torchvision
  ];

  passthru.optional-dependencies = {
    tutorials = [
      ipywidgets
      jupyter
    ];
  };

  pythonImportsCheck = [
    "compressai"
    "compressai._CXX"
  ];

  preCheck = ''
    # We have to delete the source because otherwise it is used intead the installed package.
    rm -rf compressai

    export HOME=$(mktemp -d)
  '';

  nativeCheckInputs = [
    plotly
    pytestCheckHook
  ];

  disabledTests = [
    # Those tests require internet access to download some weights
    "test_image_codec"
    "test_update"
    "test_eval_model_pretrained"
    "test_cheng2020_anchor"
    "test_pretrained"
  ];

  meta = with lib; {
    description = "A PyTorch library and evaluation platform for end-to-end compression research";
    homepage = "https://github.com/InterDigitalInc/CompressAI";
    license = licenses.bsd3Clear;
    maintainers = with maintainers; [ GaetanLepage ];
  };
}