Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds@gmail.com>2021-05-24 13:34:56 +0200
committerAnton Hvornum <anton.feeds@gmail.com>2021-05-24 13:34:56 +0200
commit2ee88e0e3ab2aa2af836427f5d9e87059a6952c8 (patch)
tree6ed321850dddfeb6eeb7dd426150fdbb83c8679c
parent9b0de26c67b6bb90b69d5b4ef874dc0bed407a77 (diff)
Switched plugin strategty. Now uses built-in entrypoints to source and load the plugins. This is the default method provided by Python, and is the cleanest so far I think.
-rw-r--r--archinstall/lib/plugins.py28
1 files changed, 7 insertions, 21 deletions
diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py
index f7f8bc4e..d838da91 100644
--- a/archinstall/lib/plugins.py
+++ b/archinstall/lib/plugins.py
@@ -1,24 +1,10 @@
-import pkgutil
-import importlib
-import imp # Deprecated
-from .storage import storage
+from importlib import metadata
plugins = {}
-PLUGIN_PREFIXES = 'archinstall-'
-if (plugin_list := storage.get('plugins', None)):
- if type(plugin_list) == str and plugin_list != '*':
- plugin_list = plugin_list.split(',')
-
- for module_info in pkgutil.iter_modules(path=None, prefix=''):
- if not module_info.ispkg:
- continue
-
- # If --plugins=* and <iterator:plugin> == 'archinstall-'
- # of --plugins=name is <iterator:plugin>
- if (plugin_list == '*' and PLUGIN_PREFIXES in module_info.name) or (module_info.name in plugin_list):
- try:
- modulesource = importlib.import_module(module_info.name)
- imp.reload(modulesource)
- except Exception as e:
- print('Could not load plugin {} {}'.format(modname, e)) \ No newline at end of file
+# 1: List archinstall.plugin definitions
+# 2: Loade the plugin entry point
+# 3: Initiate the plugin and store it as .name in plugins
+for plugin_definition in metadata.entry_points()['archinstall.plugin']:
+ plugin_entrypoint = plugin_definition.load()
+ plugins[plugin_definition.name] = plugin_entrypoint() \ No newline at end of file