From b570779036cbb62da7c38433039fe71b6e08544a Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Thu, 29 May 2025 20:08:21 +1000 Subject: [PATCH 1/2] Fix 3530 --- archinstall/lib/plugins.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index f4bf7e5525..3c0635d4fb 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -7,8 +7,8 @@ from importlib import metadata from pathlib import Path +from .args import arch_config_handler from .output import error, info, warn -from .storage import storage plugins = {} @@ -74,13 +74,6 @@ def _import_via_path(path: Path, namespace: str | None = None) -> str | None: 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)) @@ -98,10 +91,12 @@ def load_plugin(path: Path) -> None: if namespace and namespace in sys.modules: # 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 version is not None: + version_major_and_minor = version.rsplit('.', 1)[0] - if sys.modules[namespace].__archinstall__version__ < archinstall_major_and_minor_version: + 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() From bfb408257f211756af3b517360ea9a5a540cbafe Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Thu, 29 May 2025 21:24:53 +1000 Subject: [PATCH 2/2] Update --- archinstall/lib/plugins.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/archinstall/lib/plugins.py b/archinstall/lib/plugins.py index 3c0635d4fb..a2998bf3b4 100644 --- a/archinstall/lib/plugins.py +++ b/archinstall/lib/plugins.py @@ -7,7 +7,6 @@ from importlib import metadata from pathlib import Path -from .args import arch_config_handler from .output import error, info, warn plugins = {} @@ -89,6 +88,8 @@ 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. version = arch_config_handler.config.version