Skip to content

Commit 79aa779

Browse files
committed
allow single-element list as 'sources' value in exts_list
1 parent 8633146 commit 79aa779

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

easybuild/framework/easyblock.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,12 +547,20 @@ def fetch_extension_sources(self, skip_checksums=False):
547547

548548
if ext_options.get('nosource', None):
549549
exts_sources.append(ext_src)
550+
550551
elif ext_options.get('sources', None):
551552
sources = ext_options['sources']
552-
if isinstance(sources, (list, tuple)):
553-
raise EasyBuildError("'sources' entry to 'exts_list' must be a single dictionary.")
554553

555-
src = self.fetch_source(sources, checksums, extension=True)
554+
if isinstance(sources, list):
555+
if len(sources) == 1:
556+
source = sources[0]
557+
else:
558+
error_msg = "'sources' spec for %s in exts_list must be single element list"
559+
raise EasyBuildError(error_msg, ext_name, sources)
560+
else:
561+
source = sources
562+
563+
src = self.fetch_source(source, checksums, extension=True)
556564
# Copy 'path' entry to 'src' for use with extensions
557565
ext_src.update({'src': src['path']})
558566
exts_sources.append(ext_src)

test/framework/toy_build.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,8 +1196,48 @@ def test_toy_extension_patches(self):
11961196

11971197
self.test_toy_build(ec_file=test_ec)
11981198

1199-
def test_toy_extension_sources(self):
1200-
"""Test install toy that includes extensions with full sources."""
1199+
def test_toy_extension_sources_single_item_list(self):
1200+
"""Test install toy that includes extensions with 'sources' spec (as single-item list)."""
1201+
test_ecs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
1202+
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')
1203+
toy_ec_txt = read_file(toy_ec)
1204+
1205+
test_ec = os.path.join(self.test_prefix, 'test.eb')
1206+
1207+
# test use of single-element list in 'sources' with just the filename
1208+
test_ec_txt = '\n'.join([
1209+
toy_ec_txt,
1210+
'exts_list = [',
1211+
' ("bar", "0.0", {',
1212+
' "sources": ["bar-%(version)s.tar.gz"],',
1213+
' }),',
1214+
']',
1215+
])
1216+
write_file(test_ec, test_ec_txt)
1217+
self.test_toy_build(ec_file=test_ec)
1218+
1219+
def test_toy_extension_sources_str(self):
1220+
"""Test install toy that includes extensions with 'sources' spec (as string value)."""
1221+
test_ecs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
1222+
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')
1223+
toy_ec_txt = read_file(toy_ec)
1224+
1225+
test_ec = os.path.join(self.test_prefix, 'test.eb')
1226+
1227+
# test use of single-element list in 'sources' with just the filename
1228+
test_ec_txt = '\n'.join([
1229+
toy_ec_txt,
1230+
'exts_list = [',
1231+
' ("bar", "0.0", {',
1232+
' "sources": "bar-%(version)s.tar.gz",',
1233+
' }),',
1234+
']',
1235+
])
1236+
write_file(test_ec, test_ec_txt)
1237+
self.test_toy_build(ec_file=test_ec)
1238+
1239+
def test_toy_extension_sources_git_config(self):
1240+
"""Test install toy that includes extensions with 'sources' spec including 'git_config'."""
12011241
test_ecs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')
12021242
toy_ec = os.path.join(test_ecs, 't', 'toy', 'toy-0.0.eb')
12031243
toy_ec_txt = read_file(toy_ec)
@@ -1230,7 +1270,6 @@ def test_toy_extension_sources(self):
12301270
']',
12311271
])
12321272
write_file(test_ec, test_ec_txt)
1233-
12341273
self.test_toy_build(ec_file=test_ec)
12351274

12361275
def test_toy_module_fulltxt(self):

0 commit comments

Comments
 (0)