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 = pname;
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 dontUseSetuptoolsCheck = true; # looks for pytest-runner
41 preCheck = ''
42 echo "Temporarily moving tests to $OUT to find cython modules"
43 export PACKAGEDIR=$out/${python.sitePackages}
44 cp -r $TMP/source/tests $PACKAGEDIR
45 pushd $PACKAGEDIR
46 '';
47 postCheck = ''
48 rm -rf tests
49 popd
50 '';
51
52 meta = with lib; {
53 description = "Python implementation of FastDTW (Dynamic Time Warping)";
54 longDescription = ''
55 FastDTW is an approximate Dynamic Time Warping (DTW) algorithm that provides
56 optimal or near-optimal alignments with an O(N) time and memory complexity.
57 '';
58 homepage = "https://github.com/slaypni/fastdtw";
59 license = licenses.mit;
60 maintainers = with maintainers; [ drewrisinger ];
61 };
62}