Skip to content

Commit 459450c

Browse files
committed
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.
1 parent 501c568 commit 459450c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

easybuild/framework/easyblock.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ def extra_options(extra=None):
138138

139139
return extra
140140

141+
@staticmethod
142+
def src_keys():
143+
"""
144+
Return list of EasyConfig parameter that contribute to the sources in the `src` member
145+
(or equivalently to the `sources` parameter of a parsed EasyConfig)
146+
"""
147+
return ['sources']
148+
141149
#
142150
# INIT
143151
#
@@ -4752,7 +4760,7 @@ def make_checksum_lines(checksums, indent_level):
47524760
placeholder = '# PLACEHOLDER FOR SOURCES/PATCHES WITH CHECKSUMS'
47534761

47544762
# grab raw lines for the following params
4755-
keys = ['source_urls', 'sources', 'crates', 'patches']
4763+
keys = ['source_urls'] + app.src_keys() + ['patches']
47564764
raw = {}
47574765
for key in keys:
47584766
regex = re.compile(r'^(%s(?:.|\n)*?\])\s*$' % key, re.M)

test/framework/sandbox/easybuild/easyblocks/generic/cargo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def extra_options():
3737
}
3838
return EasyBlock.extra_options(extra_vars)
3939

40+
@staticmethod
41+
def src_keys():
42+
return super(Cargo, Cargo).src_keys() + ['crates']
43+
4044
def __init__(self, *args, **kwargs):
4145
"""Constructor for Cargo easyblock."""
4246
super(Cargo, self).__init__(*args, **kwargs)

0 commit comments

Comments
 (0)