From: 
Subject: Debian changes

The Debian packaging of python-pyopen-wakeword is maintained in git, using a workflow
similar to the one described in dgit-maint-merge(7).
The Debian delta is represented by this one combined patch; there isn't a
patch queue that can be represented as a quilt series.

A detailed breakdown of the changes is available from their canonical
representation -- git commits in the packaging repository.
For example, to see the changes made by the Debian maintainer in the first
upload of upstream version 1.2.3, you could use:

    % git clone https://git.dgit.debian.org/python-pyopen-wakeword
    % cd python-pyopen-wakeword
    % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'

(If you have dgit, use `dgit clone python-pyopen-wakeword`, rather than plain `git clone`.)

We don't use debian/source/options single-debian-patch because it has bugs.
Therefore, NMUs etc. may nevertheless have made additional patches.

---

diff --git a/pyopen_wakeword/openwakeword.py b/pyopen_wakeword/openwakeword.py
index eb8dfcf..687f41a 100644
--- a/pyopen_wakeword/openwakeword.py
+++ b/pyopen_wakeword/openwakeword.py
@@ -1,6 +1,7 @@
 """openWakeWord implementation."""
 
 import ctypes as C
+import ctypes.util
 from collections.abc import Iterable
 from pathlib import Path
 from typing import Final, Optional, Union
@@ -8,13 +9,11 @@ from typing import Final, Optional, Union
 import numpy as np
 
 from .const import Model
-from .wakeword import TfLiteWakeWord, get_platform
+from .wakeword import TfLiteWakeWord
 
 _DIR = Path(__file__).parent
-_REPO_DIR = _DIR.parent
-_MODULE_LIB_DIR = _DIR / "lib"
-_REPO_LIB_DIR = _REPO_DIR / "lib"
 _MODELS_DIR = _DIR / "models"
+_SYSTEM_TENSORFLOW_LITE = "tensorflow-lite"
 
 c_void_p = C.c_void_p
 c_int32 = C.c_int32
@@ -389,22 +388,10 @@ class OpenWakeWordFeatures(TfLiteWakeWord):
 # -----------------------------------------------------------------------------
 
 
-def _find_tensorflowlite_c() -> Path:
-    # Try module lib dir first (inside wheel)
-    libtensorflowlite_c_path = next(
-        iter(_MODULE_LIB_DIR.glob("*tensorflowlite_c.*")), None
-    )
+def _find_tensorflowlite_c() -> str:
+    libtensorflowlite_c_path = ctypes.util.find_library(_SYSTEM_TENSORFLOW_LITE)
 
     if not libtensorflowlite_c_path:
-        # Try repo dir
-        platform = get_platform()
-        if not platform:
-            raise ValueError("Unable to detect platform for tensorflowlite_c")
-
-        lib_dir = _REPO_LIB_DIR / platform
-        libtensorflowlite_c_path = next(iter(lib_dir.glob("*tensorflowlite_c.*")), None)
-
-    if not libtensorflowlite_c_path:
-        raise ValueError("Failed to find tensorflowlite_c library")
+        raise ValueError("Failed to find TensorFlow Lite library")
 
     return libtensorflowlite_c_path
diff --git a/pyopen_wakeword/wakeword.py b/pyopen_wakeword/wakeword.py
index 26fcd01..982813f 100644
--- a/pyopen_wakeword/wakeword.py
+++ b/pyopen_wakeword/wakeword.py
@@ -2,10 +2,9 @@
 
 import ctypes as C
 import os
-import platform
 import sys
 from pathlib import Path
-from typing import Optional, Union
+from typing import Union
 
 TfLiteStatus = C.c_int  # kTfLiteOk == 0
 
@@ -27,7 +26,13 @@ def _not_null(result, func, args):
 
 class TfLiteWakeWord:
     def __init__(self, libtensorflowlite_c_path: Union[str, Path]):
-        self.libtensorflowlite_c_path = Path(libtensorflowlite_c_path).resolve()
+        libtensorflowlite_c_path = os.fspath(libtensorflowlite_c_path)
+        if os.path.dirname(libtensorflowlite_c_path):
+            self.libtensorflowlite_c_path: Union[str, Path] = Path(
+                libtensorflowlite_c_path
+            ).resolve()
+        else:
+            self.libtensorflowlite_c_path = libtensorflowlite_c_path
 
         if sys.platform == "win32":
             self.lib = C.CDLL(str(self.libtensorflowlite_c_path))
@@ -97,28 +102,3 @@ class TfLiteWakeWord:
         lib.TfLiteInterpreterDelete.restype = None
         lib.TfLiteModelDelete.argtypes = [c_void_p]
         lib.TfLiteModelDelete.restype = None
-
-
-def get_platform() -> Optional[str]:
-    machine = platform.machine().lower()
-    is_arm = ("arm" in machine) or ("aarch" in machine)
-    is_amd64 = machine in ("x86_64", "amd64")
-    system = sys.platform
-
-    if system.startswith("linux"):
-        if is_arm:
-            return "linux_arm64"
-
-        if is_amd64:
-            return "linux_amd64"
-
-    if system == "win32":
-        if is_amd64:
-            return "windows_amd64"
-
-    if system == "darwin":
-        if is_arm:
-            return "darwin_arm64"
-
-    # Not supported
-    return None
diff --git a/pyproject.toml b/pyproject.toml
index 3d0a19b..b7a8502 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -31,6 +31,9 @@ dependencies = [
 [project.urls]
 "Source Code" = "https://github.com/rhasspy/pyopen-wakeword"
 
+[project.scripts]
+pyopen-wakeword = "pyopen_wakeword.__main__:main"
+
 [tool.setuptools]
 platforms = ["any"]
 zip-safe  = false
