File hg-fast-export-fix_pluginloader.patch of Package hg-fast-export
diff -urN fast-export-231118/pluginloader/__init__.py fast-export-231118-patch/pluginloader/__init__.py
--- fast-export-231118/pluginloader/__init__.py 2023-03-27 21:35:36.000000000 +0300
+++ fast-export-231118-patch/pluginloader/__init__.py 2025-03-31 13:46:46.658958760 +0300
@@ -1,19 +1,24 @@
import os
-import imp
+import importlib.machinery
+import importlib.util
PluginFolder = os.path.join(os.path.dirname(os.path.realpath(__file__)),"..","plugins")
MainModule = "__init__"
def get_plugin(name, plugin_path):
- search_dirs = [PluginFolder]
+ search_dirs = [PluginFolder, '.']
if plugin_path:
search_dirs = [plugin_path] + search_dirs
for dir in search_dirs:
location = os.path.join(dir, name)
if not os.path.isdir(location) or not MainModule + ".py" in os.listdir(location):
continue
- info = imp.find_module(MainModule, [location])
- return {"name": name, "info": info, "path": location}
+ spec = importlib.machinery.PathFinder.find_spec(MainModule, [location])
+ return {"name": name, "spec": spec, "path": location}
raise Exception("Could not find plugin with name " + name)
def load_plugin(plugin):
- return imp.load_module(MainModule, *plugin["info"])
+ spec = plugin["spec"]
+ module = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(module)
+ return module
+