1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchpatch,
6 cython,
7 numpy,
8 # Check Inputs
9 pytestCheckHook,
10 python,
11}:
12
13buildPythonPackage rec {
14 pname = "fastdtw";
15 version = "0.3.4";
16 format = "setuptools";
17
18 src = fetchFromGitHub {
19 owner = "slaypni";
20 repo = "fastdtw";
21 rev = "v${version}";
22 sha256 = "0irc5x4ahfp7f7q4ic97qa898s2awi0vdjznahxrfjirn8b157dw";
23 };
24
25 patches = [
26 # Removes outdated cythonized C++ file, which doesn't match CPython. Will be auto-used if left.
27 # Remove when PR 40 merged
28 (fetchpatch {
29 url = "https://patch-diff.githubusercontent.com/raw/slaypni/fastdtw/pull/40.patch";
30 sha256 = "0xjma0h84bk1n32wgk99rwfc85scp187a7fykhnylmcc73ppal9q";
31 })
32 ];
33
34 nativeBuildInputs = [ cython ];
35
36 propagatedBuildInputs = [ numpy ];
37
38 pythonImportsCheck = [ "fastdtw.fastdtw" ];
39 nativeCheckInputs = [ pytestCheckHook ];
40 preCheck = ''
41 echo "Temporarily moving tests to $OUT to find cython modules"
42 export PACKAGEDIR=$out/${python.sitePackages}
43 cp -r $TMP/source/tests $PACKAGEDIR
44 pushd $PACKAGEDIR
45 '';
46 postCheck = ''
47 rm -rf tests
48 popd
49 '';
50
51 meta = with lib; {
52 description = "Python implementation of FastDTW (Dynamic Time Warping)";
53 longDescription = ''
54 FastDTW is an approximate Dynamic Time Warping (DTW) algorithm that provides
55 optimal or near-optimal alignments with an O(N) time and memory complexity.
56 '';
57 homepage = "https://github.com/slaypni/fastdtw";
58 license = licenses.mit;
59 maintainers = with maintainers; [ drewrisinger ];
60 };
61}