Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'whatis' easyconfig parameter #1271

Merged
merged 10 commits into from
Nov 27, 2015
1 change: 1 addition & 0 deletions easybuild/framework/easyconfig/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
'exts_list': [[], 'List with extensions added to the base installation', EXTENSIONS],

# MODULES easyconfig parameters
'whatis': [None, "List of brief (one line) package description entries", MODULES],
'modaliases': [{}, "Aliases to be defined in module file", MODULES],
'modextrapaths': [{}, "Extra paths to be prepended in module file", MODULES],
'modextravars': [{}, "Extra environment variables to be added to module file", MODULES],
Expand Down
20 changes: 15 additions & 5 deletions easybuild/tools/module_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,19 @@ def get_description(self, conflict=True):
"""
description = "%s - Homepage: %s" % (self.app.cfg['description'], self.app.cfg['homepage'])

whatis = self.app.cfg['whatis']
if whatis is None:
# default: include single 'whatis' statement with description as contents
whatis = [description]

lines = [
self.MODULE_HEADER.replace('%', '%%'),
"proc ModulesHelp { } {",
" puts stderr { %(description)s",
" }",
'}',
'',
"module-whatis {Description: %(description)s}",
'%(whatis_lines)s',
'',
"set root %(installdir)s",
]
Expand All @@ -190,6 +195,7 @@ def get_description(self, conflict=True):
'name': self.app.name,
'version': self.app.version,
'description': description,
'whatis_lines': '\n'.join(["module-whatis {%s}" % line for line in whatis]),
'installdir': self.app.installdir,
}

Expand Down Expand Up @@ -332,12 +338,15 @@ def get_description(self, conflict=True):

description = "%s - Homepage: %s" % (self.app.cfg['description'], self.app.cfg['homepage'])

whatis = self.app.cfg['whatis']
if whatis is None:
# default: include single 'whatis' statement with description as contents
whatis = [description]

lines = [
"help([[%(description)s]])",
"whatis([[Name: %(name)s]])",
"whatis([[Version: %(version)s]])",
"whatis([[Description: %(description)s]])",
"whatis([[Homepage: %(homepage)s]])",
'',
"%(whatis_lines)s",
'',
'local root = "%(installdir)s"',
]
Expand All @@ -353,6 +362,7 @@ def get_description(self, conflict=True):
'name': self.app.name,
'version': self.app.version,
'description': description,
'whatis_lines': '\n'.join(["whatis([[%s]])" % line for line in whatis]),
'installdir': self.app.installdir,
'homepage': self.app.cfg['homepage'],
}
Expand Down
43 changes: 38 additions & 5 deletions test/framework/module_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_descr(self):
" }",
"}",
'',
"module-whatis {Description: %s}" % gzip_txt,
"module-whatis {%s}" % gzip_txt,
'',
"set root %s" % self.modgen.app.installdir,
'',
Expand All @@ -94,10 +94,43 @@ def test_descr(self):
else:
expected = '\n'.join([
'help([[%s]])' % gzip_txt,
"whatis([[Name: gzip]])" ,
"whatis([[Version: 1.4]])" ,
"whatis([[Description: %s]])" % gzip_txt,
"whatis([[Homepage: http://www.gzip.org/]])",
'',
"whatis([[%s]])" % gzip_txt,
'',
'local root = "%s"' % self.modgen.app.installdir,
'',
'conflict("gzip")',
'',
])

desc = self.modgen.get_description()
self.assertEqual(desc, expected)

# Test description with list of 'whatis' strings
self.eb.cfg['whatis'] = ['foo', 'bar']
if self.MODULE_GENERATOR_CLASS == ModuleGeneratorTcl:
expected = '\n'.join([
"#%Module",
"proc ModulesHelp { } {",
" puts stderr { %s" % gzip_txt,
" }",
"}",
'',
"module-whatis {foo}",
"module-whatis {bar}",
'',
"set root %s" % self.modgen.app.installdir,
'',
"conflict gzip",
'',
])

else:
expected = '\n'.join([
'help([[%s]])' % gzip_txt,
'',
"whatis([[foo]])",
"whatis([[bar]])",
'',
'local root = "%s"' % self.modgen.app.installdir,
'',
Expand Down
8 changes: 3 additions & 5 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,8 @@ def test_toy_module_fulltxt(self):
if get_module_syntax() == 'Lua':
mod_txt_regex_pattern = '\n'.join([
r'help\(\[\[Toy C program. - Homepage: http://hpcugent.github.com/easybuild\]\]\)',
r'whatis\(\[\[Name: toy\]\]\)',
r'whatis\(\[\[Version: 0.0\]\]\)',
r'whatis\(\[\[Description: Toy C program. - Homepage: http://hpcugent.github.com/easybuild\]\]\)',
r'whatis\(\[\[Homepage: http://hpcugent.github.com/easybuild\]\]\)',
r'',
r'whatis\(\[\[Toy C program. - Homepage: http://hpcugent.github.com/easybuild\]\]\)',
r'',
r'local root = "%s/software/toy/0.0-tweaked"' % self.test_installpath,
r'',
Expand Down Expand Up @@ -832,7 +830,7 @@ def test_toy_module_fulltxt(self):
r' }',
r'}',
r'',
r'module-whatis {Description: Toy C program. - Homepage: http://hpcugent.github.com/easybuild}',
r'module-whatis {Toy C program. - Homepage: http://hpcugent.github.com/easybuild}',
r'',
r'set root %s/software/toy/0.0-tweaked' % self.test_installpath,
r'',
Expand Down