Commit 4899b78c authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Add custom module load for GUI

parent 9d4c947b
......@@ -24,8 +24,10 @@
from ctypes.util import find_library
from packaging.version import Version as V
import gajim.gui
from gajim.common import i18n
_MIN_NBXMPP_VER = '1.99.0'
_MIN_GTK_VER = '3.22.27'
_MIN_CAIRO_VER = '1.16.0'
......@@ -102,13 +104,16 @@ def _disable_csd():
def _init_gtk():
from gajim.gtk import exception
from gajim.gui import exception
from gajim.application import GajimApplication
def _run_app():
from gajim.application import GajimApplication
application = GajimApplication()
......@@ -152,3 +157,4 @@ def main():
import sys
import importlib
from pathlib import Path
class GUIFinder(
def __init__(self, name, fallback=None):
self._path = Path(__file__).parent.parent / name
self._fallback_path = None
if fallback is not None:
self._fallback_path = Path(__file__).parent.parent / fallback
self._suffix = 'pyc' if sys.platform == 'win32' else 'py'
def find_spec(self, fullname, _path, _target=None):
if not fullname.startswith('gajim.gui'):
return None
_namespace, module_name = fullname.rsplit('.', 1)
module_path = self._path / f'{module_name}.{self._suffix}'
if not module_path.exists():
if self._fallback_path is None:
return None
module_path = self._fallback_path / f'{module_name}.{self._suffix}'
if not module_path.exists():
return None
spec = importlib.util.spec_from_file_location(fullname, module_path)
return spec
def init(name, fallback=None):
sys.meta_path.append(GUIFinder(name, fallback=fallback))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment