From 8bed035e2132b59353b9f61afd5000dd2390fe7b Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Thu, 29 May 2025 21:54:28 +1000 Subject: [PATCH] Fix 3530 (#3535) * Fix 3530 * Update --- archinstall/lib/plugins.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index c1d0d8f9..c4dd3489 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -8,7 +8,6 @@ from importlib import metadata from pathlib import Path from .output import error, info, warn -from .storage import storage plugins = {} @@ -74,13 +73,6 @@ def _import_via_path(path: Path, namespace: str | None = None) -> str: return namespace -def _find_nth(haystack: list[str], needle: str, n: int) -> int | None: - indices = [idx for idx, elem in enumerate(haystack) if elem == needle] - if n <= len(indices): - return indices[n - 1] - return None - - def load_plugin(path: Path) -> None: namespace: str | None = None parsed_url = urllib.parse.urlparse(str(path)) @@ -96,12 +88,16 @@ def load_plugin(path: Path) -> None: namespace = _import_via_path(localized) if namespace and namespace in sys.modules: + from .args import arch_config_handler + # Version dependency via __archinstall__version__ variable (if present) in the plugin # Any errors in version inconsistency will be handled through normal error handling if not defined. - if hasattr(sys.modules[namespace], '__archinstall__version__'): - archinstall_major_and_minor_version = float(storage['__version__'][: _find_nth(storage['__version__'], '.', 2)]) + version = arch_config_handler.config.version - if sys.modules[namespace].__archinstall__version__ < archinstall_major_and_minor_version: + if version is not None: + version_major_and_minor = version.rsplit('.', 1)[0] + + if sys.modules[namespace].__archinstall__version__ < float(version_major_and_minor): error(f'Plugin {sys.modules[namespace]} does not support the current Archinstall version.') # Locate the plugin entry-point called Plugin()