about summary refs log tree commit diff
path: root/pkgs/development/python-modules/fastdtw/default.nix
blob: 09c03c5b433c50ed25abca6ec9f56f440339d238 (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
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch,
  cython,
  numpy,
  # Check Inputs
  pytestCheckHook,
  python,
}:

buildPythonPackage rec {
  pname = "fastdtw";
  version = "0.3.4";
  format = "setuptools";

  src = fetchFromGitHub {
    owner = "slaypni";
    repo = pname;
    rev = "v${version}";
    sha256 = "0irc5x4ahfp7f7q4ic97qa898s2awi0vdjznahxrfjirn8b157dw";
  };

  patches = [
    # Removes outdated cythonized C++ file, which doesn't match CPython. Will be auto-used if left.
    # Remove when PR 40 merged
    (fetchpatch {
      url = "https://patch-diff.githubusercontent.com/raw/slaypni/fastdtw/pull/40.patch";
      sha256 = "0xjma0h84bk1n32wgk99rwfc85scp187a7fykhnylmcc73ppal9q";
    })
  ];

  nativeBuildInputs = [ cython ];

  propagatedBuildInputs = [ numpy ];

  pythonImportsCheck = [ "fastdtw.fastdtw" ];
  nativeCheckInputs = [ pytestCheckHook ];
  dontUseSetuptoolsCheck = true; # looks for pytest-runner
  preCheck = ''
    echo "Temporarily moving tests to $OUT to find cython modules"
    export PACKAGEDIR=$out/${python.sitePackages}
    cp -r $TMP/source/tests $PACKAGEDIR
    pushd $PACKAGEDIR
  '';
  postCheck = ''
    rm -rf tests
    popd
  '';

  meta = with lib; {
    description = "Python implementation of FastDTW (Dynamic Time Warping)";
    longDescription = ''
      FastDTW is an approximate Dynamic Time Warping (DTW) algorithm that provides
      optimal or near-optimal alignments with an O(N) time and memory complexity.
    '';
    homepage = "https://github.com/slaypni/fastdtw";
    license = licenses.mit;
    maintainers = with maintainers; [ drewrisinger ];
  };
}