Skip to content

Commit 17e4c5e

Browse files
committed
fix error when --easystack is used without having PyYAML installed
1 parent dea39f5 commit 17e4c5e

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

easybuild/framework/easystack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def __init__(self, name, version, versionsuffix, toolchain_version, toolchain_na
8686
class EasyStackParser(object):
8787
"""Parser for easystack files (in YAML syntax)."""
8888

89-
@only_if_module_is_available('yaml', pkgname='PyYAML')
9089
@staticmethod
9190
def parse(filepath):
9291
"""Parses YAML file and assigns obtained values to SW config instances as well as general config instance"""
@@ -211,6 +210,7 @@ def parse(filepath):
211210
return easystack
212211

213212

213+
@only_if_module_is_available('yaml', pkgname='PyYAML')
214214
def parse_easystack(filepath):
215215
"""Parses through easystack file, returns what EC are to be installed together with their options."""
216216
log_msg = "Support for easybuild-ing from multiple easyconfigs based on "

easybuild/tools/utilities.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,18 @@ def wrap(orig):
173173
pass
174174

175175
if imported is None:
176-
raise ImportError("None of the specified modules (%s) is available" % ', '.join(modnames))
176+
raise ImportError
177177
else:
178178
return orig
179179

180-
except ImportError as err:
181-
# need to pass down 'err' via named argument to ensure it's in scope when using Python 3.x
182-
def error(err=err, *args, **kwargs):
183-
msg = "%s; required module '%s' is not available" % (err, modname)
180+
except ImportError:
181+
def error(*args, **kwargs):
182+
msg = "None of the specified modules (%s) is available" % ', '.join(modnames)
184183
if pkgname:
185184
msg += " (provided by Python package %s, available from %s)" % (pkgname, url)
186185
elif url:
187186
msg += " (available from %s)" % url
187+
msg += ", yet one of them is required!"
188188
raise EasyBuildError("ImportError: %s", msg)
189189
return error
190190

test/framework/general.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def foo2():
8181
def bar():
8282
pass
8383

84-
err_pat = "required module 'nosuchmoduleoutthere' is not available.*package nosuchpkg.*pypi/nosuchpkg"
84+
err_pat = r"None of the specified modules \(nosuchmoduleoutthere\) is available.*"
85+
err_pat += r"package nosuchpkg.*pypi/nosuchpkg"
8586
self.assertErrorRegex(EasyBuildError, err_pat, bar)
8687

8788
@only_if_module_is_available(('nosuchmodule', 'anothernosuchmodule'))
@@ -96,7 +97,8 @@ class Foo():
9697
def foobar(self):
9798
pass
9899

99-
err_pat = r"required module 'thisdoesnotexist' is not available \(available from http://example.com\)"
100+
err_pat = r"None of the specified modules \(thisdoesnotexist\) is available "
101+
err_pat += r"\(available from http://example.com\)"
100102
self.assertErrorRegex(EasyBuildError, err_pat, Foo().foobar)
101103

102104
def test_docstrings(self):

0 commit comments

Comments
 (0)