From 459450cfb3379b0b98f87c0c0e045657ee8cc1d9 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 9 Oct 2024 12:45:41 +0200 Subject: [PATCH] Add customization point for easyblocks to specify additional parameters for "sources" Some easyblocks such as `Cargo` will use a custom EasyConfig parameters to fill the `sources` list. To avoid hard-coding them `inject_checksums` introduce a static method `src_parameter_names` to return a list of parameters that contribute to the final list of `sources` when parsing the EasyConfig. --- easybuild/framework/easyblock.py | 10 +++++++++- .../sandbox/easybuild/easyblocks/generic/cargo.py | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/easybuild/framework/easyblock.py b/easybuild/framework/easyblock.py index 42d072844f..4b971a7323 100644 --- a/easybuild/framework/easyblock.py +++ b/easybuild/framework/easyblock.py @@ -138,6 +138,14 @@ def extra_options(extra=None): return extra + @staticmethod + def src_keys(): + """ + Return list of EasyConfig parameter that contribute to the sources in the `src` member + (or equivalently to the `sources` parameter of a parsed EasyConfig) + """ + return ['sources'] + # # INIT # @@ -4752,7 +4760,7 @@ def make_checksum_lines(checksums, indent_level): placeholder = '# PLACEHOLDER FOR SOURCES/PATCHES WITH CHECKSUMS' # grab raw lines for the following params - keys = ['source_urls', 'sources', 'crates', 'patches'] + keys = ['source_urls'] + app.src_keys() + ['patches'] raw = {} for key in keys: regex = re.compile(r'^(%s(?:.|\n)*?\])\s*$' % key, re.M) diff --git a/test/framework/sandbox/easybuild/easyblocks/generic/cargo.py b/test/framework/sandbox/easybuild/easyblocks/generic/cargo.py index 403ba6725c..495bf9dc5b 100644 --- a/test/framework/sandbox/easybuild/easyblocks/generic/cargo.py +++ b/test/framework/sandbox/easybuild/easyblocks/generic/cargo.py @@ -37,6 +37,10 @@ def extra_options(): } return EasyBlock.extra_options(extra_vars) + @staticmethod + def src_keys(): + return super(Cargo, Cargo).src_keys() + ['crates'] + def __init__(self, *args, **kwargs): """Constructor for Cargo easyblock.""" super(Cargo, self).__init__(*args, **kwargs)