From 6d458cbba49f7b4fd91413b27ef1f871b26446b0 Mon Sep 17 00:00:00 2001 From: Markus Geimer Date: Wed, 29 Apr 2015 17:49:24 +0200 Subject: [PATCH 1/5] Add support for 'whatis' easyconfig parameter and proper "module whatis" output generation --- easybuild/framework/easyconfig/default.py | 1 + easybuild/tools/module_generator.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/easybuild/framework/easyconfig/default.py b/easybuild/framework/easyconfig/default.py index 64cf46be16..04ce41fa37 100644 --- a/easybuild/framework/easyconfig/default.py +++ b/easybuild/framework/easyconfig/default.py @@ -155,6 +155,7 @@ 'exts_list': [[], 'List with extensions added to the base installation', EXTENSIONS], # MODULES easyconfig parameters + 'whatis': [{}, "Brief (one line) package description", MODULES], 'modextrapaths': [{}, "Extra paths to be prepended in module file", MODULES], 'modextravars': [{}, "Extra environment variables to be added to module file", MODULES], 'modloadmsg': [{}, "Message that should be printed when generated module is loaded", MODULES], diff --git a/easybuild/tools/module_generator.py b/easybuild/tools/module_generator.py index 1332f3f3e5..cc160ca68e 100644 --- a/easybuild/tools/module_generator.py +++ b/easybuild/tools/module_generator.py @@ -163,6 +163,10 @@ def get_description(self, conflict=True): """ description = "%s - Homepage: %s" % (self.app.cfg['description'], self.app.cfg['homepage']) + whatis = self.app.cfg['whatis'] + if not whatis: + whatis = description + lines = [ self.MODULE_HEADER.replace('%', '%%'), "proc ModulesHelp { } {", @@ -170,7 +174,7 @@ def get_description(self, conflict=True): " }", '}', '', - "module-whatis {Description: %(description)s}", + "module-whatis {%(whatis)s}", '', "set root %(installdir)s", ] @@ -191,6 +195,7 @@ def get_description(self, conflict=True): 'name': self.app.name, 'version': self.app.version, 'description': description, + 'whatis': whatis, 'installdir': self.app.installdir, } @@ -322,11 +327,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 not whatis: + whatis = description + lines = [ "help = [[%(description)s]]", "whatis([[Name: %(name)s]])", "whatis([[Version: %(version)s]])", - "whatis([[Description: %(description)s]])", + "whatis([[Description: %(whatis)s]])", "whatis([[Homepage: %(homepage)s]])", '', 'local root = "%(installdir)s"', @@ -343,6 +352,7 @@ def get_description(self, conflict=True): 'name': self.app.name, 'version': self.app.version, 'description': description, + 'whatis': whatis, 'installdir': self.app.installdir, 'homepage': self.app.cfg['homepage'], } From 3a61e916c531b17b856f901fda84acb73bff6519 Mon Sep 17 00:00:00 2001 From: Markus Geimer Date: Wed, 29 Apr 2015 18:53:20 +0200 Subject: [PATCH 2/5] Bring unit tests in line with adjusted output --- test/framework/module_generator.py | 2 +- test/framework/toy_build.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/framework/module_generator.py b/test/framework/module_generator.py index f898bf913f..cc743fdac8 100644 --- a/test/framework/module_generator.py +++ b/test/framework/module_generator.py @@ -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, '', diff --git a/test/framework/toy_build.py b/test/framework/toy_build.py index 2a577f3b3b..b6de45b019 100644 --- a/test/framework/toy_build.py +++ b/test/framework/toy_build.py @@ -805,7 +805,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'', From 47416fb5ca0754c61d79c2c4d36dff0f0d629af2 Mon Sep 17 00:00:00 2001 From: Markus Geimer Date: Fri, 13 Nov 2015 03:51:58 +0100 Subject: [PATCH 3/5] Allow to specify a list of `whatis` strings, each resulting in a separate whatis statement in the modulefile --- easybuild/framework/easyconfig/default.py | 2 +- easybuild/tools/module_generator.py | 16 ++++----- test/framework/module_generator.py | 41 ++++++++++++++++++++--- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/easybuild/framework/easyconfig/default.py b/easybuild/framework/easyconfig/default.py index c8e55b5197..32d87836c7 100644 --- a/easybuild/framework/easyconfig/default.py +++ b/easybuild/framework/easyconfig/default.py @@ -155,7 +155,7 @@ 'exts_list': [[], 'List with extensions added to the base installation', EXTENSIONS], # MODULES easyconfig parameters - 'whatis': [{}, "Brief (one line) package description", MODULES], + 'whatis': [[], "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], diff --git a/easybuild/tools/module_generator.py b/easybuild/tools/module_generator.py index 1d371afab9..60ba8f9834 100644 --- a/easybuild/tools/module_generator.py +++ b/easybuild/tools/module_generator.py @@ -164,7 +164,7 @@ def get_description(self, conflict=True): whatis = self.app.cfg['whatis'] if not whatis: - whatis = description + whatis = [description] lines = [ self.MODULE_HEADER.replace('%', '%%'), @@ -173,7 +173,7 @@ def get_description(self, conflict=True): " }", '}', '', - "module-whatis {%(whatis)s}", + '%(whatis_lines)s', '', "set root %(installdir)s", ] @@ -194,7 +194,7 @@ def get_description(self, conflict=True): 'name': self.app.name, 'version': self.app.version, 'description': description, - 'whatis': whatis, + 'whatis_lines': "\n".join(("module-whatis {%s}" % line) for line in whatis), 'installdir': self.app.installdir, } @@ -339,14 +339,12 @@ def get_description(self, conflict=True): whatis = self.app.cfg['whatis'] if not whatis: - whatis = description + whatis = [description] lines = [ "help([[%(description)s]])", - "whatis([[Name: %(name)s]])", - "whatis([[Version: %(version)s]])", - "whatis([[Description: %(whatis)s]])", - "whatis([[Homepage: %(homepage)s]])", + '', + "%(whatis_lines)s", '', 'local root = "%(installdir)s"', ] @@ -362,7 +360,7 @@ def get_description(self, conflict=True): 'name': self.app.name, 'version': self.app.version, 'description': description, - 'whatis': whatis, + 'whatis_lines': "\n".join(("whatis([[%s]])" % line) for line in whatis), 'installdir': self.app.installdir, 'homepage': self.app.cfg['homepage'], } diff --git a/test/framework/module_generator.py b/test/framework/module_generator.py index 3e523754e9..3b2eaaa869 100644 --- a/test/framework/module_generator.py +++ b/test/framework/module_generator.py @@ -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.update('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, '', From 1c3caa6a079fb74d2abfec3dd29f660130334191 Mon Sep 17 00:00:00 2001 From: Markus Geimer Date: Fri, 13 Nov 2015 16:42:11 +0100 Subject: [PATCH 4/5] Fix toy_build test --- test/framework/toy_build.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/framework/toy_build.py b/test/framework/toy_build.py index b81cdde258..b09bf8843b 100644 --- a/test/framework/toy_build.py +++ b/test/framework/toy_build.py @@ -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'', From 4f997d2bd51dce34bb21e74e359a8c82dbe1ec80 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Thu, 26 Nov 2015 20:29:50 +0100 Subject: [PATCH 5/5] use None as default value for whatis + minor style fixes --- easybuild/framework/easyconfig/default.py | 2 +- easybuild/tools/module_generator.py | 10 ++++++---- test/framework/module_generator.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/easybuild/framework/easyconfig/default.py b/easybuild/framework/easyconfig/default.py index 32d87836c7..ba914bfdbc 100644 --- a/easybuild/framework/easyconfig/default.py +++ b/easybuild/framework/easyconfig/default.py @@ -155,7 +155,7 @@ 'exts_list': [[], 'List with extensions added to the base installation', EXTENSIONS], # MODULES easyconfig parameters - 'whatis': [[], "List of brief (one line) package description entries", MODULES], + '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], diff --git a/easybuild/tools/module_generator.py b/easybuild/tools/module_generator.py index fd61ffabc8..7aa43128ef 100644 --- a/easybuild/tools/module_generator.py +++ b/easybuild/tools/module_generator.py @@ -163,7 +163,8 @@ def get_description(self, conflict=True): description = "%s - Homepage: %s" % (self.app.cfg['description'], self.app.cfg['homepage']) whatis = self.app.cfg['whatis'] - if not whatis: + if whatis is None: + # default: include single 'whatis' statement with description as contents whatis = [description] lines = [ @@ -194,7 +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), + 'whatis_lines': '\n'.join(["module-whatis {%s}" % line for line in whatis]), 'installdir': self.app.installdir, } @@ -338,7 +339,8 @@ def get_description(self, conflict=True): description = "%s - Homepage: %s" % (self.app.cfg['description'], self.app.cfg['homepage']) whatis = self.app.cfg['whatis'] - if not whatis: + if whatis is None: + # default: include single 'whatis' statement with description as contents whatis = [description] lines = [ @@ -360,7 +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), + 'whatis_lines': '\n'.join(["whatis([[%s]])" % line for line in whatis]), 'installdir': self.app.installdir, 'homepage': self.app.cfg['homepage'], } diff --git a/test/framework/module_generator.py b/test/framework/module_generator.py index 8d5a9c919b..1e35535a88 100644 --- a/test/framework/module_generator.py +++ b/test/framework/module_generator.py @@ -107,7 +107,7 @@ def test_descr(self): self.assertEqual(desc, expected) # Test description with list of 'whatis' strings - self.eb.cfg.update('whatis', ['foo', 'bar']) + self.eb.cfg['whatis'] = ['foo', 'bar'] if self.MODULE_GENERATOR_CLASS == ModuleGeneratorTcl: expected = '\n'.join([ "#%Module",