From ccdfbe96d588d83e8c961c913803e4ae8f09b38b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Sep 2020 12:33:56 +0530 Subject: [PATCH] No need to manipulate sys.path when importing calibre extensions in frozen builds --- src/calibre/constants.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 6664ecc10c..2891e67fac 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -214,7 +214,8 @@ class Plugins(collections.Mapping): def load_plugin(self, name): if name in self._plugins: return - sys.path.insert(0, plugins_loc) + if not isfrozen: + sys.path.insert(0, plugins_loc) try: del sys.modules[name] except KeyError: @@ -229,7 +230,8 @@ class Plugins(collections.Mapping): except Exception: plugin_err = as_unicode(native_string_type(err), encoding=preferred_encoding, errors='replace') self._plugins[name] = p, plugin_err - sys.path.remove(plugins_loc) + if not isfrozen: + sys.path.remove(plugins_loc) def __iter__(self): return iter(self.plugins)