From: 
Subject: Debian changes

The Debian packaging of python-pymicro-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-pymicro-wakeword
    % cd python-pymicro-wakeword
    % git log --oneline 1.2.3..debian/1.2.3-1 -- . ':!debian'

(If you have dgit, use `dgit clone python-pymicro-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/pymicro_wakeword/microwakeword.py b/pymicro_wakeword/microwakeword.py
index 7182bfb..49ec5ea 100644
--- a/pymicro_wakeword/microwakeword.py
+++ b/pymicro_wakeword/microwakeword.py
@@ -1,4 +1,5 @@
 import ctypes
+import ctypes.util
 import json
 import logging
 import statistics
@@ -11,13 +12,11 @@ import numpy as np
 from pymicro_features import MicroFrontend
 
 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"
 
 _LOGGER = logging.getLogger(__name__)
 
@@ -159,24 +158,12 @@ class MicroWakeWord(TfLiteWakeWord):
         micro_config = config["micro"]
 
         if libtensorflowlite_c_path is None:
-            # Try module lib dir first (inside wheel)
-            libtensorflowlite_c_path = next(
-                iter(_MODULE_LIB_DIR.glob("*tensorflowlite_c.*")), None
+            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 MicroWakeWord(
             id=Path(config["model"]).stem,
diff --git a/pymicro_wakeword/wakeword.py b/pymicro_wakeword/wakeword.py
index 34d3937..982813f 100644
--- a/pymicro_wakeword/wakeword.py
+++ b/pymicro_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,34 +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_arm64 = ("aarch" in machine) or (machine == "arm64")
-    # 32-bit ARM (armv6l/armv7l/armv8l/armhf). Must be checked separately from
-    # is_arm64: a 32-bit process needs the 32-bit lib, not the aarch64 one.
-    is_arm32 = machine.startswith("armv") or machine in ("arm", "armhf", "armel")
-    is_amd64 = machine in ("x86_64", "amd64")
-    system = sys.platform
-
-    if system.startswith("linux"):
-        if is_arm64:
-            return "linux_arm64"
-
-        if is_arm32:
-            return "linux_armv7l"
-
-        if is_amd64:
-            return "linux_amd64"
-
-    if system == "win32":
-        if is_amd64:
-            return "windows_amd64"
-
-    if system == "darwin":
-        if is_arm64:
-            return "darwin_arm64"
-
-    # Not supported
-    return None
diff --git a/pyproject.toml b/pyproject.toml
index 38e93cc..312de35 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -33,6 +33,9 @@ dependencies = [
 [project.urls]
 "Source Code" = "https://github.com/OHF-Voice/pymicro-wakeword"
 
+[project.scripts]
+pymicro-wakeword = "pymicro_wakeword.__main__:main"
+
 [tool.setuptools]
 platforms = ["any"]
 zip-safe  = false
