summary refs log tree commit diff
path: root/pkgs/development/python-modules/pot/default.nix
blob: 8bc7ecb7f355db6c8c4f075288fcd3bd601f2a3a (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
{ lib
, fetchPypi
, buildPythonPackage
, numpy
, scipy
, cython
, matplotlib
, scikit-learn
, cupy
, pymanopt
, autograd
, pytestCheckHook
, enableDimensionalityReduction ? false
, enableGPU ? false
}:

buildPythonPackage rec {
  pname = "pot";
  version = "0.8.1.0";

  src = fetchPypi {
    pname = "POT";
    inherit version;
    sha256 = "ff2974418fbf35b18072555c2a9e7e4f6876eddfb6791179ddb8f0f6d6032505";
  };

  postPatch = ''
    substituteInPlace setup.cfg \
      --replace "--cov-report= --cov=ot" ""
  '';

  nativeBuildInputs = [ numpy cython ];
  propagatedBuildInputs = [ numpy scipy ]
    ++ lib.optionals enableGPU [ cupy ]
    ++ lib.optionals enableDimensionalityReduction [ pymanopt autograd ];
  checkInputs = [ matplotlib scikit-learn pytestCheckHook ];

  # To prevent importing of an incomplete package from the build directory
  # instead of nix store (`ot` is the top-level package name).
  preCheck = ''
    rm -r ot
  '';

  # GPU tests are always skipped because of sandboxing
  disabledTests = [ "warnings" ];

  pythonImportsCheck = [ "ot" "ot.lp" ];

  meta = {
    description = "Python Optimal Transport Library";
    homepage = "https://pythonot.github.io/";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ yl3dy ];
  };
}