Skip to content

Commit 652f0f3

Browse files
committed
Eliminate direct 'git_config' use in 'exts_list'. Clarify sanity checks done in fetch_source and fetch_sources.
1 parent 40fa3a5 commit 652f0f3

File tree

2 files changed

+13
-47
lines changed

2 files changed

+13
-47
lines changed

easybuild/framework/easyblock.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def get_checksum_for(self, checksums, filename=None, index=None):
341341
else:
342342
raise EasyBuildError("Invalid type for checksums (%s), should be list, tuple or None.", type(checksums))
343343

344-
def fetch_source(self, source=None, checksum=None, extension=False):
344+
def fetch_source(self, source, checksum=None, extension=False):
345345
"""
346346
Get a specific source (tarball, iso, url)
347347
Will be tested for existence or can be located
@@ -353,7 +353,7 @@ def fetch_source(self, source=None, checksum=None, extension=False):
353353
filename, download_filename, extract_cmd, source_urls, git_config = None, None, None, None, None
354354

355355
if source is None:
356-
raise EasyBuildError("Fetch_source called without 'source' argument")
356+
raise EasyBuildError("fetch_source called with empty 'source' argument")
357357
elif isinstance(source, string_type):
358358
filename = source
359359
elif isinstance(source, dict):
@@ -415,14 +415,14 @@ def fetch_sources(self, sources=None, checksums=None):
415415

416416
# Loop over the list of sources; list of checksums must match >= in size
417417
for index, source in enumerate(sources):
418-
if source:
419-
got_src = self.fetch_source(source, self.get_checksum_for(checksums=checksums, index=index))
420-
if got_src:
421-
self.src.append(got_src)
422-
else:
423-
raise EasyBuildError("Unable to retrieve source %s", source)
418+
if source is None:
419+
raise EasyBuildError("Empty source in sources list at index %d", index)
420+
421+
src_spec = self.fetch_source(source, self.get_checksum_for(checksums=checksums, index=index))
422+
if src_spec:
423+
self.src.append(src_spec)
424424
else:
425-
raise EasyBuildError("Empty source in list at index %d", index)
425+
raise EasyBuildError("Unable to retrieve source %s", source)
426426

427427
self.log.info("Added sources: %s", self.src)
428428

@@ -549,17 +549,18 @@ def fetch_extension_sources(self, skip_checksums=False):
549549
exts_sources.append(ext_src)
550550
elif ext_options.get('sources', None):
551551
sources = ext_options['sources']
552+
if isinstance(sources, (list,tuple)):
553+
raise EasyBuildError("'sources' entry to 'exts_list' must be a single dictionary.")
554+
552555
src = self.fetch_source(sources, checksums, extension=True)
553556
# Copy 'path' entry to 'src' for use with extensions
554557
ext_src.update({'src': src['path']})
555558
exts_sources.append(ext_src)
556559
else:
557560
source_urls = ext_options.get('source_urls', [])
558561
force_download = build_option('force_download') in [FORCE_DOWNLOAD_ALL, FORCE_DOWNLOAD_SOURCES]
559-
git_config = ext_options.get('git_config', None)
560562

561-
src_fn = self.obtain_file(fn, extension=True, urls=source_urls, force_download=force_download,
562-
git_config=git_config)
563+
src_fn = self.obtain_file(fn, extension=True, urls=source_urls, force_download=force_download)
563564

564565
if src_fn:
565566
ext_src.update({'src': src_fn})

test/framework/toy_build.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,41 +1196,6 @@ def test_toy_extension_patches(self):
11961196

11971197
self.test_toy_build(ec_file=test_ec)
11981198

1199-
def test_toy_extension_git(self):
1200-
"""Test install toy that includes extensions with git_config."""
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-
# Tar-ball which should be created via 'git_config', and one file
1206-
ext_tgz = 'exts-git.tar.gz'
1207-
ext_tarball = os.path.join(self.test_sourcepath, 't', 'toy', ext_tgz)
1208-
ext_tarfile = 'a_directory/a_file.txt'
1209-
1210-
# Dummy source code required for extensions build_step to pass
1211-
ext_src = 'int main() { return 0; }'
1212-
ext_cfile = 'exts-git.c'
1213-
1214-
test_ec = os.path.join(self.test_prefix, 'test.eb')
1215-
test_ec_txt = '\n'.join([
1216-
toy_ec_txt,
1217-
'prebuildopts = "echo \\\"%s\\\" > %s && ",' % (ext_src, ext_cfile),
1218-
'exts_list = [',
1219-
' ("exts-git", "0.0", {',
1220-
' "buildopts": "&& ls -l %s %s",' % (ext_tarball, ext_tarfile),
1221-
' "source_tmpl": "%s",' % ext_tgz,
1222-
' "git_config": {',
1223-
' "repo_name": "testrepository",',
1224-
' "url": "https://github.com/easybuilders",',
1225-
' "tag": "master",',
1226-
' },',
1227-
' }),',
1228-
']',
1229-
])
1230-
write_file(test_ec, test_ec_txt)
1231-
1232-
self.test_toy_build(ec_file=test_ec)
1233-
12341199
def test_toy_extension_sources(self):
12351200
"""Test install toy that includes extensions with full sources."""
12361201
test_ecs = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs', 'test_ecs')

0 commit comments

Comments
 (0)