From 76796f5f23bb0bfe5f7aed542c5e539aedf18f3e Mon Sep 17 00:00:00 2001 From: deepend Date: Sun, 22 Feb 2026 11:03:57 -0700 Subject: [PATCH] Fixed Python plugin module discovery to search multiple valid install layouts before importing zoitechat, instead of assuming only one path. This includes: existing sibling fallback (../python) direct fallback (libdir/python) AppImage-aware fallbacks under $APPDIR/usr/lib/zoitechat/python and $APPDIR/usr/lib/x86_64-linux-gnu/zoitechat/python. Added guards so paths are appended only if the directory exists and is not already in sys.path, reducing duplicate/invalid entries while improving robustness across packaging layouts. --- plugins/python/python.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/python/python.py b/plugins/python/python.py index bab732f7..93c56040 100644 --- a/plugins/python/python.py +++ b/plugins/python/python.py @@ -538,8 +538,22 @@ def _on_plugin_init(plugin_name, plugin_desc, plugin_version, arg, libdir): try: libdir = __decode(_cstr(libdir)) - modpath = os.path.join(libdir, '..', 'python') - sys.path.append(os.path.abspath(modpath)) + modpaths = [ + os.path.abspath(os.path.join(libdir, '..', 'python')), + os.path.abspath(os.path.join(libdir, 'python')), + ] + + appdir = os.getenv('APPDIR') + if appdir: + modpaths.extend([ + os.path.join(appdir, 'usr', 'lib', 'zoitechat', 'python'), + os.path.join(appdir, 'usr', 'lib', 'x86_64-linux-gnu', 'zoitechat', 'python'), + ]) + + for modpath in modpaths: + if os.path.isdir(modpath) and modpath not in sys.path: + sys.path.append(modpath) + zoitechat = importlib.import_module('zoitechat') except (UnicodeDecodeError, ImportError) as e: