From 163ae47dcce731852134150c203e24b7b5a3db8c Mon Sep 17 00:00:00 2001
From: Maksym Balatsko <maksym.balatsko-ext@arista.com>
Date: Sat, 16 Sep 2023 09:36:09 -0700
Subject: [PATCH] python3Packages.dtw-python: init at 1.3.0

---
 .../python-modules/dtw-python/default.nix     | 57 +++++++++++++++++++
 pkgs/top-level/python-packages.nix            |  2 +
 2 files changed, 59 insertions(+)
 create mode 100644 pkgs/development/python-modules/dtw-python/default.nix

diff --git a/pkgs/development/python-modules/dtw-python/default.nix b/pkgs/development/python-modules/dtw-python/default.nix
new file mode 100644
index 000000000000..f50102fe6210
--- /dev/null
+++ b/pkgs/development/python-modules/dtw-python/default.nix
@@ -0,0 +1,57 @@
+{ lib
+, buildPythonPackage
+, fetchFromGitHub
+, cython
+, oldest-supported-numpy
+, setuptools
+, wheel
+, scipy
+, numpy
+, pytestCheckHook
+, pythonOlder
+}:
+
+buildPythonPackage rec {
+  pname = "dtw-python";
+  version = "1.3.0";
+  format = "pyproject";
+
+  disable = pythonOlder "3.6";
+
+  src = fetchFromGitHub {
+    owner = "DynamicTimeWarping";
+    repo = "dtw-python";
+    rev = "v${version}";
+    hash = "sha256-7hQuo7dES9f08YZhCf+kxUkMlrr+bg1P7HHRCMv3bLk=";
+  };
+
+  nativeBuildInputs = [
+    cython
+    oldest-supported-numpy
+    setuptools
+    wheel
+  ];
+
+  propagatedBuildInputs = [
+    scipy
+    numpy
+  ];
+
+  # We need to run tests on real built package: https://github.com/NixOS/nixpkgs/issues/255262
+  preCheck = "cd $out";
+  nativeCheckInputs = [ pytestCheckHook ];
+  # tests/ are not included to output package, so we have to set path explicitly
+  pytestFlagsArray = [
+    "$src/tests"
+  ];
+
+  pythonImportsCheck = [ "dtw" ];
+
+  meta = with lib; {
+    description = "Python port of R's Comprehensive Dynamic Time Warp algorithms package";
+    homepage = "https://github.com/DynamicTimeWarping/dtw-python";
+    changelog = "https://github.com/DynamicTimeWarping/dtw-python/blob/${src.rev}/CHANGELOG.md";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ mbalatsko ];
+  };
+}
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 4cf1f0a21474..acfa1bf6c914 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -3254,6 +3254,8 @@ self: super: with self; {
 
   dtschema = callPackage ../development/python-modules/dtschema { };
 
+  dtw-python = callPackage ../development/python-modules/dtw-python { };
+
   ducc0 = callPackage ../development/python-modules/ducc0 { };
 
   duckdb = callPackage ../development/python-modules/duckdb {