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.
This commit is contained in:
2026-02-22 11:03:57 -07:00
parent 796c572292
commit 76796f5f23

View File

@@ -538,8 +538,22 @@ def _on_plugin_init(plugin_name, plugin_desc, plugin_version, arg, libdir):
try: try:
libdir = __decode(_cstr(libdir)) libdir = __decode(_cstr(libdir))
modpath = os.path.join(libdir, '..', 'python') modpaths = [
sys.path.append(os.path.abspath(modpath)) 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') zoitechat = importlib.import_module('zoitechat')
except (UnicodeDecodeError, ImportError) as e: except (UnicodeDecodeError, ImportError) as e: