From: Roland Mas <lolando@debian.org>
Date: Wed, 16 Aug 2023 16:45:49 +0200
Subject: Lookup path for private lib

---
 source/tomopy/util/extern/__init__.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/source/tomopy/util/extern/__init__.py b/source/tomopy/util/extern/__init__.py
index 48f3da3..485670d 100644
--- a/source/tomopy/util/extern/__init__.py
+++ b/source/tomopy/util/extern/__init__.py
@@ -49,6 +49,8 @@
 import ctypes
 import ctypes.util
 import os
+import subprocess
+import sys
 import warnings
 
 
@@ -72,6 +74,21 @@ def c_shared_lib(lib_name, error=True):
         except OSError:
             pass
 
+    try:
+        path = os.path.dirname(os.path.realpath(__file__))
+        sharedlib = os.path.join(path,'lib%s.so'%(lib_name,))
+        return load_dll(sharedlib)
+    except OSError:
+        pass
+
+    try:
+        path = os.path.dirname(os.path.realpath(__file__))
+        arch = subprocess.check_output(["dpkg-architecture", "--query", "DEB_HOST_MULTIARCH"], text=True).strip()
+        sharedlib = os.path.join(path,'lib%s.cpython-%d%d-%s.so'%(lib_name,sys.version_info.major,sys.version_info.minor,arch))
+        return load_dll(sharedlib)
+    except OSError:
+        raise
+
     explanation = (
         'TomoPy links to compiled components which are installed separately'
         ' and loaded using ctypes.util.find_library().'
