def __init__(self, *args, **kwargs):
        """Initialize either as EasyBlock or as Extension."""

        self.is_extension = False

        if isinstance(args[0], EasyBlock):
            # make sure that extra custom easyconfig parameters are known
            extra_params = self.__class__.extra_options()
            kwargs['extra_params'] = extra_params

            Extension.__init__(self, *args, **kwargs)

            # name and version properties of EasyBlock are used, so make sure name and version are correct
            self.cfg['name'] = self.ext.get('name', None)
            self.cfg['version'] = self.ext.get('version', None)
            # We can't inherit the 'start_dir' value from the parent (which will be set, and will most likely be wrong).
            # It should be specified for the extension specifically, or be empty (so it is auto-derived).
            self.cfg['start_dir'] = self.ext.get('options', {}).get('start_dir', None)
            self.builddir = self.master.builddir
            self.installdir = self.master.installdir
            self.modules_tool = self.master.modules_tool
            self.module_generator = self.master.module_generator
            self.is_extension = True
            self.unpack_options = None
        else:
            EasyBlock.__init__(self, *args, **kwargs)
            self.options = copy.deepcopy(self.cfg.get('options', {}))  # we need this for Extension.sanity_check_step

        self.ext_dir = None  # dir where extension source was unpacked
    def sanity_check_step(self, exts_filter=None, custom_paths=None, custom_commands=None):
        """
        Custom sanity check for extensions, whether installed as stand-alone module or not
        """
        if not self.cfg["exts_filter"]:
            self.cfg["exts_filter"] = exts_filter
        self.log.debug("starting sanity check for extension with filter %s", self.cfg["exts_filter"])

        if not self.is_extension:
            # load fake module
            fake_mod_data = self.load_fake_module(purge=True)

        # perform sanity check
        sanity_check_ok = Extension.sanity_check_step(self)

        if not self.is_extension:
            # unload fake module and clean up
            self.clean_up_fake_module(fake_mod_data)

        if custom_paths or self.cfg["sanity_check_paths"] or custom_commands or self.cfg["sanity_check_commands"]:
            EasyBlock.sanity_check_step(
                self, custom_paths=custom_paths, custom_commands=custom_commands, extension=self.is_extension
            )

        # pass or fail sanity check
        if not sanity_check_ok:
            msg = "Sanity check for %s failed: %s" % (self.name, "; ".join(self.sanity_check_fail_msgs))
            if self.is_extension:
                self.log.warning(msg)
            else:
                self.log.error(msg)
            return False
        else:
            self.log.info("Sanity check for %s successful!" % self.name)
            return True
Example #3
0
 def test_exts_list(self):
     """Test handling of list of extensions."""
     self.contents = '\n'.join([
         'name = "pi"',
         'version = "3.14"',
         'homepage = "http://example.com"',
         'description = "test easyconfig"',
         'toolchain = {"name": "dummy", "version": "dummy"}',
         'exts_list = [',
         '   ("ext1", "ext_ver1", {',
         '       "source_tmpl": "gzip-1.4.eb",',  # dummy source template to avoid downloading fail
         '       "source_urls": ["http://example.com/"]',
         '   }),',
         '   ("ext2", "ext_ver2", {',
         '       "source_tmpl": "gzip-1.4.eb",',  # dummy source template to avoid downloading fail
         '       "source_urls": [("http://example.com", "suffix")],'
         '       "patches": ["toy-0.0.eb"],',  # dummy patch to avoid downloading fail
         '       "checksums": [',
         '           "673085af5622393e543b9ea31f66c590",',  # checksum for source (gzip-1.4.eb)
         '           "5e82b0e9faa5753545bb6da12d88d04b",',  # checksum for patch ()
         '       ],',
         '   }),',
         ']',
     ])
     self.prep()
     eb = EasyBlock(self.eb_file)
     exts_sources = eb.fetch_extension_sources()
Example #4
0
    def test_buildininstalldir(self):
        """Test specifying build in install dir."""
        config.variables['buildpath'] = tempfile.mkdtemp()
        config.variables['installpath'] = tempfile.mkdtemp()
        self.contents = '\n'.join([
            'name = "pi"',
            'version = "3.14"',
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            'toolchain = {"name": "dummy", "version": "dummy"}',
            'buildininstalldir = True',
        ])
        self.prep()
        eb = EasyBlock(self.eb_file)
        eb.gen_builddir()
        eb.mod_name = det_full_module_name(eb.cfg)  # required by gen_installdir()
        eb.gen_installdir()
        eb.make_builddir()
        eb.make_installdir()
        self.assertEqual(eb.builddir, eb.installdir)
        self.assertTrue(os.path.isdir(eb.builddir))

        # cleanup
        shutil.rmtree(config.variables['buildpath'])
        shutil.rmtree(config.variables['installpath'])
 def test_exts_list(self):
     """Test handling of list of extensions."""
     os.environ['EASYBUILD_SOURCEPATH'] = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs')
     init_config()
     self.contents = '\n'.join([
         'name = "pi"',
         'version = "3.14"',
         'homepage = "http://example.com"',
         'description = "test easyconfig"',
         'toolchain = {"name": "dummy", "version": "dummy"}',
         'exts_list = [',
         '   ("ext1", "ext_ver1", {',
         '       "source_tmpl": "gzip-1.4.eb",',  # dummy source template to avoid downloading fail
         '       "source_urls": ["http://example.com/"]',
         '   }),',
         '   ("ext2", "ext_ver2", {',
         '       "source_tmpl": "gzip-1.4.eb",',  # dummy source template to avoid downloading fail
         '       "source_urls": [("http://example.com", "suffix")],'
         '       "patches": ["toy-0.0.eb"],',  # dummy patch to avoid downloading fail
         '       "checksums": [',
         '           "504c7036558938f997c1c269a01d7458",',  # checksum for source (gzip-1.4.eb)
         '           "ddd5161154f5db67701525123129ff09",',  # checksum for patch (toy-0.0.eb)
         '       ],',
         '   }),',
         ']',
     ])
     self.prep()
     ec = EasyConfig(self.eb_file)
     eb = EasyBlock(ec)
     exts_sources = eb.fetch_extension_sources()
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to Binary easyblock."""
     extra_vars = dict(EasyBlock.extra_options(extra_vars))
     extra_vars.update({
         'install_cmd': [None, "Install command to be used.", CUSTOM],
     })
     return EasyBlock.extra_options(extra_vars)
    def test_make_module_req(self):
        """Testcase for make_module_req"""
        self.contents = '\n'.join([
            'name = "pi"',
            'version = "3.14"',
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            'toolchain = {"name":"dummy", "version": "dummy"}',
        ])
        self.writeEC()
        eb = EasyBlock(EasyConfig(self.eb_file))
        eb.installdir = config.install_path()

        # create fake directories and files that should be guessed
        os.makedirs(eb.installdir)
        open(os.path.join(eb.installdir, 'foo.jar'), 'w').write('foo.jar')
        open(os.path.join(eb.installdir, 'bla.jar'), 'w').write('bla.jar')
        os.mkdir(os.path.join(eb.installdir, 'bin'))
        os.mkdir(os.path.join(eb.installdir, 'share'))
        os.mkdir(os.path.join(eb.installdir, 'share', 'man'))
        # this is not a path that should be picked up
        os.mkdir(os.path.join(eb.installdir, 'CPATH'))

        guess = eb.make_module_req()

        self.assertTrue(re.search("^prepend-path\s+CLASSPATH\s+\$root/bla.jar$", guess, re.M))
        self.assertTrue(re.search("^prepend-path\s+CLASSPATH\s+\$root/foo.jar$", guess, re.M))
        self.assertTrue(re.search("^prepend-path\s+MANPATH\s+\$root/share/man$", guess, re.M))
        self.assertTrue(re.search("^prepend-path\s+PATH\s+\$root/bin$", guess, re.M))
        self.assertFalse(re.search("^prepend-path\s+CPATH\s+.*$", guess, re.M))

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
    def sanity_check_step(self, exts_filter, custom_paths=None, custom_commands=None):
        """
        Custom sanity check for extensions, whether installed as stand-alone module or not
        """
        if not self.cfg["exts_filter"]:
            self.cfg["exts_filter"] = exts_filter

        if not self.is_extension:
            # load fake module
            fake_mod_data = self.load_fake_module(purge=True)

        # perform sanity check
        sanity_check_ok = Extension.sanity_check_step(self)

        if not self.is_extension:
            # unload fake module and clean up
            self.clean_up_fake_module(fake_mod_data)

        if custom_paths or custom_commands:
            EasyBlock.sanity_check_step(self, custom_paths=custom_paths, custom_commands=custom_commands)

        # pass or fail sanity check
        if not sanity_check_ok:
            if self.is_extension:
                self.log.warning("Sanity check for %s failed!" % self.name)
            else:
                self.log.error("Sanity check for %s failed!" % self.name)
            return False
        else:
            self.log.info("Sanity check for %s successful!" % self.name)
            return True
Example #9
0
    def runTest(self):
        """ extra_options should allow other variables to be stored """
        eb = EasyBlock(self.eb_file)
        self.assertRaises(KeyError, lambda: eb['custom_key'])

        extra_vars = { 'custom_key': ['default', "This is a default key"]}

        eb = EasyBlock(self.eb_file, extra_vars)
        self.assertEqual(eb['custom_key'], 'default')

        eb['custom_key'] = "not so default"
        self.assertEqual(eb['custom_key'], 'not so default')

        self.contents += "\ncustom_key = 'test'"

        self.setUp()

        eb = EasyBlock(self.eb_file, extra_vars)
        self.assertEqual(eb['custom_key'], 'test')

        eb['custom_key'] = "not so default"
        self.assertEqual(eb['custom_key'], 'not so default')

        # test if extra toolkit options are being passed
        self.assertEqual(eb.toolkit().opts['static'], True)
Example #10
0
    def test_make_module_step(self):
        """Test the make_module_step"""
        name = "pi"
        version = "3.14"
        deps = [("GCC", "4.6.4")]
        hiddendeps = [("toy", "0.0-deps")]
        alldeps = deps + hiddendeps  # hidden deps must be included in list of deps
        modextravars = {"PI": "3.1415", "FOO": "bar"}
        modextrapaths = {"PATH": "pibin", "CPATH": "pi/include"}
        self.contents = "\n".join(
            [
                'name = "%s"' % name,
                'version = "%s"' % version,
                'homepage = "http://example.com"',
                'description = "test easyconfig"',
                "toolchain = {'name': 'dummy', 'version': 'dummy'}",
                "dependencies = %s" % str(alldeps),
                "hiddendependencies = %s" % str(hiddendeps),
                "builddependencies = [('OpenMPI', '1.6.4-GCC-4.6.4')]",
                "modextravars = %s" % str(modextravars),
                "modextrapaths = %s" % str(modextrapaths),
            ]
        )

        test_dir = os.path.dirname(os.path.abspath(__file__))
        os.environ["MODULEPATH"] = os.path.join(test_dir, "modules")

        # test if module is generated correctly
        self.writeEC()
        ec = EasyConfig(self.eb_file)
        eb = EasyBlock(ec)
        # eb.builddir = self.test_buildpath
        eb.installdir = os.path.join(config.install_path(), "pi", "3.14")
        eb.check_readiness_step()

        modpath = os.path.join(eb.make_module_step(), name, version)
        self.assertTrue(os.path.exists(modpath), "%s exists" % modpath)

        # verify contents of module
        f = open(modpath, "r")
        txt = f.read()
        f.close()
        self.assertTrue(re.search("^#%Module", txt.split("\n")[0]))
        self.assertTrue(re.search("^conflict\s+%s$" % name, txt, re.M))
        self.assertTrue(re.search("^set\s+root\s+%s$" % eb.installdir, txt, re.M))
        self.assertTrue(re.search('^setenv\s+EBROOT%s\s+".root"\s*$' % name.upper(), txt, re.M))
        self.assertTrue(re.search('^setenv\s+EBVERSION%s\s+"%s"$' % (name.upper(), version), txt, re.M))
        for (key, val) in modextravars.items():
            regex = re.compile('^setenv\s+%s\s+"%s"$' % (key, val), re.M)
            self.assertTrue(regex.search(txt), "Pattern %s found in %s" % (regex.pattern, txt))
        for (key, val) in modextrapaths.items():
            regex = re.compile("^prepend-path\s+%s\s+\$root/%s$" % (key, val), re.M)
            self.assertTrue(regex.search(txt), "Pattern %s found in %s" % (regex.pattern, txt))
        for (name, ver) in deps:
            regex = re.compile("^\s*module load %s\s*$" % os.path.join(name, ver), re.M)
            self.assertTrue(regex.search(txt), "Pattern %s found in %s" % (regex.pattern, txt))
        for (name, ver) in hiddendeps:
            regex = re.compile("^\s*module load %s/.%s\s*$" % (name, ver), re.M)
            self.assertTrue(regex.search(txt), "Pattern %s found in %s" % (regex.pattern, txt))
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to ConfigureMake."""
     extra_vars = dict(EasyBlock.extra_options(extra_vars))
     extra_vars.update({
         'tar_config_opts': [False, "Override tar settings as determined by configure.", CUSTOM],
         'prefix_opt': ['--prefix=', "Prefix command line option for configure script", CUSTOM],
     })
     return EasyBlock.extra_options(extra_vars)
Example #12
0
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to RPMs."""
     extra_vars = dict(EasyBlock.extra_options(extra_vars))
     extra_vars.update({
         'force': [False, "Use force", CUSTOM],
         'preinstall': [False, "Enable pre install", CUSTOM],
         'postinstall': [False, "Enable post install", CUSTOM],
         'makesymlinks': [[], "Create symlinks for listed paths", CUSTOM],  # supports glob
     })
     return EasyBlock.extra_options(extra_vars)
Example #13
0
    def test_exclude_path_to_top_of_module_tree(self):
        """
        Make sure that modules under the HierarchicalMNS are correct,
        w.r.t. not including any load statements for modules that build up the path to the top of the module tree.
        """
        self.orig_module_naming_scheme = config.get_module_naming_scheme()
        test_ecs_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'easyconfigs')
        all_stops = [x[0] for x in EasyBlock.get_steps()]
        build_options = {
            'check_osdeps': False,
            'robot_path': [test_ecs_path],
            'valid_stops': all_stops,
            'validate': False,
        }
        os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = 'HierarchicalMNS'
        init_config(build_options=build_options)
        self.setup_hierarchical_modules()

        modfile_prefix = os.path.join(self.test_installpath, 'modules', 'all')
        mkdir(os.path.join(modfile_prefix, 'Compiler', 'GCC', '4.8.3'), parents=True)
        mkdir(os.path.join(modfile_prefix, 'MPI', 'intel', '2013.5.192-GCC-4.8.3', 'impi', '4.1.3.049'), parents=True)

        impi_modfile_path = os.path.join('Compiler', 'intel', '2013.5.192-GCC-4.8.3', 'impi', '4.1.3.049')
        imkl_modfile_path = os.path.join('MPI', 'intel', '2013.5.192-GCC-4.8.3', 'impi', '4.1.3.049', 'imkl', '11.1.2.144')
        if get_module_syntax() == 'Lua':
            impi_modfile_path += '.lua'
            imkl_modfile_path += '.lua'

        # example: for imkl on top of iimpi toolchain with HierarchicalMNS, no module load statements should be included
        # not for the toolchain or any of the toolchain components,
        # since both icc/ifort and impi form the path to the top of the module tree
        tests = [
            ('impi-4.1.3.049-iccifort-2013.5.192-GCC-4.8.3.eb', impi_modfile_path, ['icc', 'ifort', 'iccifort']),
            ('imkl-11.1.2.144-iimpi-5.5.3-GCC-4.8.3.eb', imkl_modfile_path, ['icc', 'ifort', 'impi', 'iccifort', 'iimpi']),
        ]
        for ec_file, modfile_path, excluded_deps in tests:
            ec = EasyConfig(os.path.join(test_ecs_path, ec_file))
            eb = EasyBlock(ec)
            eb.toolchain.prepare()
            modpath = eb.make_module_step()
            modfile_path = os.path.join(modpath, modfile_path)
            modtxt = read_file(modfile_path)

            for dep in excluded_deps:
                tup = (dep, modfile_path, modtxt)
                failmsg = "No 'module load' statement found for '%s' not found in module %s: %s" % tup
                if get_module_syntax() == 'Tcl':
                    self.assertFalse(re.search('module load %s' % dep, modtxt), failmsg)
                elif get_module_syntax() == 'Lua':
                    self.assertFalse(re.search('load("%s")' % dep, modtxt), failmsg)
                else:
                    self.assertTrue(False, "Unknown module syntax: %s" % get_module_syntax())

        os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = self.orig_module_naming_scheme
        init_config(build_options=build_options)
Example #14
0
    def test_extensions_step(self):
        """Test the extensions_step"""
        self.contents = """
name = "pi"
version = "3.14"
homepage = "http://example.com"
description = "test easyconfig"
toolchain = {"name":"dummy", "version": "dummy"}
exts_list = ['ext1']
"""
        self.writeEC()
        """Testcase for extensions"""
        # test for proper error message without the exts_defaultclass set
        eb = EasyBlock(self.eb_file)
        eb.installdir = config.variables['installpath']
        self.assertRaises(EasyBuildError, eb.extensions_step)
        self.assertErrorRegex(EasyBuildError, "No default extension class set", eb.extensions_step)

        # test if everything works fine if set
        self.contents += "\nexts_defaultclass = ['easybuild.framework.extension', 'Extension']"
        self.writeEC()
        eb = EasyBlock(self.eb_file)
        eb.builddir = config.variables['buildpath']
        eb.installdir = config.variables['installpath']
        eb.extensions_step()

        # test for proper error message when skip is set, but no exts_filter is set
        self.assertRaises(EasyBuildError, eb.skip_extensions)
        self.assertErrorRegex(EasyBuildError, "no exts_filter set", eb.skip_extensions)

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
    def test_extensions_step(self):
        """Test the extensions_step"""
        self.contents = '\n'.join([
            'easyblock = "ConfigureMake"',
            'name = "pi"',
            'version = "3.14"',
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            'toolchain = {"name": "dummy", "version": "dummy"}',
            'exts_list = ["ext1"]',
        ])
        self.writeEC()
        """Testcase for extensions"""
        # test for proper error message without the exts_defaultclass set
        eb = EasyBlock(EasyConfig(self.eb_file))
        eb.installdir = config.install_path()
        self.assertRaises(EasyBuildError, eb.extensions_step, fetch=True)
        self.assertErrorRegex(EasyBuildError, "No default extension class set", eb.extensions_step, fetch=True)

        # test if everything works fine if set
        self.contents += "\nexts_defaultclass = 'DummyExtension'"
        self.writeEC()
        eb = EasyBlock(EasyConfig(self.eb_file))
        eb.builddir = config.build_path()
        eb.installdir = config.install_path()
        eb.extensions_step(fetch=True)

        # test for proper error message when skip is set, but no exts_filter is set
        self.assertRaises(EasyBuildError, eb.skip_extensions)
        self.assertErrorRegex(EasyBuildError, "no exts_filter set", eb.skip_extensions)

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
Example #16
0
    def test_exclude_path_to_top_of_module_tree(self):
        """
        Make sure that modules under the HierarchicalMNS are correct,
        w.r.t. not including any load statements for modules that build up the path to the top of the module tree.
        """
        self.orig_module_naming_scheme = config.get_module_naming_scheme()
        test_ecs_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "easyconfigs")
        all_stops = [x[0] for x in EasyBlock.get_steps()]
        build_options = {
            "check_osdeps": False,
            "robot_path": [test_ecs_path],
            "valid_stops": all_stops,
            "validate": False,
        }
        os.environ["EASYBUILD_MODULE_NAMING_SCHEME"] = "HierarchicalMNS"
        init_config(build_options=build_options)
        self.setup_hierarchical_modules()
        modtool = modules_tool()

        modfile_prefix = os.path.join(self.test_installpath, "modules", "all")
        mkdir(os.path.join(modfile_prefix, "Compiler", "GCC", "4.8.3"), parents=True)
        mkdir(os.path.join(modfile_prefix, "MPI", "intel", "2013.5.192-GCC-4.8.3", "impi", "4.1.3.049"), parents=True)

        impi_modfile_path = os.path.join("Compiler", "intel", "2013.5.192-GCC-4.8.3", "impi", "4.1.3.049")
        imkl_modfile_path = os.path.join(
            "MPI", "intel", "2013.5.192-GCC-4.8.3", "impi", "4.1.3.049", "imkl", "11.1.2.144"
        )

        # example: for imkl on top of iimpi toolchain with HierarchicalMNS, no module load statements should be included
        # not for the toolchain or any of the toolchain components,
        # since both icc/ifort and impi form the path to the top of the module tree
        tests = [
            ("impi-4.1.3.049-iccifort-2013.5.192-GCC-4.8.3.eb", impi_modfile_path, ["icc", "ifort", "iccifort"]),
            (
                "imkl-11.1.2.144-iimpi-5.5.3-GCC-4.8.3.eb",
                imkl_modfile_path,
                ["icc", "ifort", "impi", "iccifort", "iimpi"],
            ),
        ]
        for ec_file, modfile_path, excluded_deps in tests:
            ec = EasyConfig(os.path.join(test_ecs_path, ec_file))
            eb = EasyBlock(ec)
            eb.toolchain.prepare()
            modpath = eb.make_module_step()
            modfile_path = os.path.join(modpath, modfile_path)
            modtxt = read_file(modfile_path)

            for imkl_dep in excluded_deps:
                tup = (imkl_dep, modfile_path, modtxt)
                failmsg = "No 'module load' statement found for '%s' not found in module %s: %s" % tup
                self.assertFalse(re.search("module load %s" % imkl_dep, modtxt), failmsg)

        os.environ["EASYBUILD_MODULE_NAMING_SCHEME"] = self.orig_module_naming_scheme
        init_config(build_options=build_options)
    def test_fake_module_load(self):
        """Testcase for fake module load"""
        self.contents = """
name = "pi"
version = "3.14"
homepage = "http://google.com"
description = "test easyconfig"
toolchain = {"name":"dummy", "version": "dummy"}
"""
        self.writeEC()
        eb = EasyBlock(self.eb_file)
        eb.installdir = config.variables['install_path']
        eb.load_fake_module()
Example #18
0
    def test_skip_extensions_step(self):
        """Test the skip_extensions_step"""
        self.contents = """
name = "pi"
version = "3.14"
homepage = "http://example.com"
description = "test easyconfig"
toolchain = {"name":"dummy", "version": "dummy"}
exts_list = ['ext1', 'ext2']
exts_filter = ("if [ %(name)s == 'ext2' ]; then exit 0; else exit 1; fi", '')
exts_defaultclass = ['easybuild.framework.extension', 'Extension']
"""
        # check if skip skips correct extensions
        self.writeEC()
        eb = EasyBlock(self.eb_file)
        #self.assertTrue('ext1' in eb.exts.keys() and 'ext2' in eb.exts.keys())
        eb.builddir = config.variables['buildpath']
        eb.installdir = config.variables['installpath']
        eb.skip = True
        eb.extensions_step()
        # 'ext1' should be in eb.exts
        self.assertTrue('ext1' in [y for x in eb.exts for y in x.values()])
        # 'ext2' should not
        self.assertFalse('ext2' in [y for x in eb.exts for y in x.values()])

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
    def test_prepare_step(self):
        """Test prepare step (setting up build environment)."""
        test_easyconfigs = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs', 'test_ecs')
        ec = process_easyconfig(os.path.join(test_easyconfigs, 't', 'toy', 'toy-0.0.eb'))[0]

        mkdir(os.path.join(self.test_buildpath, 'toy', '0.0', 'dummy-dummy'), parents=True)
        eb = EasyBlock(ec['ec'])
        eb.silent = True
        eb.prepare_step()
        self.assertEqual(self.modtool.list(), [])

        os.environ['THIS_IS_AN_UNWANTED_ENV_VAR'] = 'foo'
        eb.cfg['unwanted_env_vars'] = ['THIS_IS_AN_UNWANTED_ENV_VAR']

        eb.cfg['allow_system_deps'] = [('Python', '1.2.3')]

        init_config(build_options={'extra_modules': ['GCC/4.7.2']})

        eb.prepare_step()

        self.assertEqual(os.environ.get('THIS_IS_AN_UNWANTED_ENV_VAR'), None)
        self.assertEqual(os.environ.get('EBROOTPYTHON'), 'Python')
        self.assertEqual(os.environ.get('EBVERSIONPYTHON'), '1.2.3')
        self.assertEqual(len(self.modtool.list()), 1)
        self.assertEqual(self.modtool.list()[0]['mod_name'], 'GCC/4.7.2')
    def test_make_module_extra(self):
        """Test for make_module_extra."""
        self.contents = '\n'.join([
            'easyblock = "ConfigureMake"',
            'name = "pi"',
            'version = "3.14"',
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            "toolchain = {'name': 'gompi', 'version': '1.1.0-no-OFED'}",
            'dependencies = [',
            "   ('FFTW', '3.3.1'),",
            "   ('LAPACK', '3.4.0'),",
            ']',
        ])
        self.writeEC()
        eb = EasyBlock(EasyConfig(self.eb_file))
        eb.installdir = os.path.join(config.install_path(), 'pi', '3.14')

        if get_module_syntax() == 'Tcl':
            expected_default = re.compile(r'\n'.join([
                r'setenv\s+EBROOTPI\s+\"\$root"',
                r'setenv\s+EBVERSIONPI\s+"3.14"',
                r'setenv\s+EBDEVELPI\s+"\$root/easybuild/pi-3.14-gompi-1.1.0-no-OFED-easybuild-devel"',
            ]))
            expected_alt = re.compile(r'\n'.join([
                r'setenv\s+EBROOTPI\s+"/opt/software/tau/6.28"',
                r'setenv\s+EBVERSIONPI\s+"6.28"',
                r'setenv\s+EBDEVELPI\s+"\$root/easybuild/pi-3.14-gompi-1.1.0-no-OFED-easybuild-devel"',
            ]))
        elif get_module_syntax() == 'Lua':
            expected_default = re.compile(r'\n'.join([
                r'setenv\("EBROOTPI", root\)',
                r'setenv\("EBVERSIONPI", "3.14"\)',
                r'setenv\("EBDEVELPI", pathJoin\(root, "easybuild/pi-3.14-gompi-1.1.0-no-OFED-easybuild-devel"\)\)',
            ]))
            expected_alt = re.compile(r'\n'.join([
                r'setenv\("EBROOTPI", "/opt/software/tau/6.28"\)',
                r'setenv\("EBVERSIONPI", "6.28"\)',
                r'setenv\("EBDEVELPI", pathJoin\(root, "easybuild/pi-3.14-gompi-1.1.0-no-OFED-easybuild-devel"\)\)',
            ]))
        else:
            self.assertTrue(False, "Unknown module syntax: %s" % get_module_syntax())

        defaulttxt = eb.make_module_extra().strip()
        self.assertTrue(expected_default.match(defaulttxt),
                        "Pattern %s found in %s" % (expected_default.pattern, defaulttxt))

        alttxt = eb.make_module_extra(altroot='/opt/software/tau/6.28', altversion='6.28').strip()
        self.assertTrue(expected_alt.match(alttxt),
                        "Pattern %s found in %s" % (expected_alt.pattern, alttxt))
    def test_skip_extensions_step(self):
        """Test the skip_extensions_step"""
        self.contents = '\n'.join([
            'easyblock = "ConfigureMake"',
            'name = "pi"',
            'version = "3.14"',
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            'toolchain = {"name": "dummy", "version": "dummy"}',
            'exts_list = ["ext1", "ext2"]',
            'exts_filter = ("if [ %(ext_name)s == \'ext2\' ]; then exit 0; else exit 1; fi", "")',
            'exts_defaultclass = "DummyExtension"',
        ])
        # check if skip skips correct extensions
        self.writeEC()
        eb = EasyBlock(EasyConfig(self.eb_file))
        eb.builddir = config.build_path()
        eb.installdir = config.install_path()
        eb.skip = True
        eb.extensions_step(fetch=True)
        # 'ext1' should be in eb.exts
        self.assertTrue('ext1' in [y for x in eb.exts for y in x.values()])
        # 'ext2' should not
        self.assertFalse('ext2' in [y for x in eb.exts for y in x.values()])

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
    def make_module_extra(self, extra=None):
        """Add custom entries to module."""

        txt = EasyBlock.make_module_extra(self)
        if not extra is None:
            txt += extra
        return txt
Example #23
0
 def extra_options():
     """Add extra easyconfig parameters custom to CHARMM."""
     extra_vars = {
         'build_options': ["FULL", "Specify the options to the build script", CUSTOM],
         'system_size': ["medium", "Specify the supported systemsize: %s" % ', '.join(KNOWN_SYSTEM_SIZES), CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #24
0
 def extra_options():
     """Custom easyconfig parameters for bar."""
     extra_vars = {
         'bar_extra1': [None, "first bar-specific easyconfig parameter (mandatory)", MANDATORY],
         'bar_extra2': ['BAR', "second bar-specific easyconfig parameter", CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #25
0
 def extra_options():
     """Add extra easyconfig parameters for Boost."""
     extra_vars = {
         'boost_mpi': [False, "Build mpi boost module", CUSTOM],
         'toolset': [None, "Toolset to use for Boost configuration ('--with-toolset for bootstrap.sh')", CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
    def extra_options():
        """Custom easyconfig parameters for ALADIN."""

        extra_vars = {
            'optional_extra_param': ['default value', "short description", CUSTOM],
        }
        return EasyBlock.extra_options(extra_vars)
Example #27
0
    def test_path_to_top_of_module_tree_categorized_hmns(self):
        """
        Test function to determine path to top of the module tree for a categorized hierarchical module naming
        scheme.
        """

        ecs_dir = os.path.join(os.path.dirname(__file__), 'easyconfigs')
        all_stops = [x[0] for x in EasyBlock.get_steps()]
        build_options = {
            'check_osdeps': False,
            'robot_path': [ecs_dir],
            'valid_stops': all_stops,
            'validate': False,
        }
        os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = 'CategorizedHMNS'
        init_config(build_options=build_options)
        self.setup_categorized_hmns_modules()
        modtool = modules_tool()
        mod_prefix = os.path.join(self.test_installpath, 'modules', 'all')
        init_modpaths = [os.path.join(mod_prefix, 'Core', 'compiler'), os.path.join(mod_prefix, 'Core', 'toolchain')]

        deps = ['GCC/4.7.2', 'OpenMPI/1.6.4', 'FFTW/3.3.3', 'OpenBLAS/0.2.6-LAPACK-3.4.2',
                'ScaLAPACK/2.0.2-OpenBLAS-0.2.6-LAPACK-3.4.2']
        path = modtool.path_to_top_of_module_tree(init_modpaths, 'goolf/1.4.10', os.path.join(mod_prefix, 'Core', 'toolchain'), deps)
        self.assertEqual(path, [])
        path = modtool.path_to_top_of_module_tree(init_modpaths, 'GCC/4.7.2', os.path.join(mod_prefix, 'Core', 'compiler'), [])
        self.assertEqual(path, [])
        full_mod_subdir = os.path.join(mod_prefix, 'Compiler', 'GCC', '4.7.2', 'mpi')
        deps = ['GCC/4.7.2', 'hwloc/1.6.2']
        path = modtool.path_to_top_of_module_tree(init_modpaths, 'OpenMPI/1.6.4', full_mod_subdir, deps)
        self.assertEqual(path, ['GCC/4.7.2'])
        full_mod_subdir = os.path.join(mod_prefix, 'MPI', 'GCC', '4.7.2', 'OpenMPI', '1.6.4', 'numlib')
        deps = ['GCC/4.7.2', 'OpenMPI/1.6.4']
        path = modtool.path_to_top_of_module_tree(init_modpaths, 'FFTW/3.3.3', full_mod_subdir, deps)
        self.assertEqual(path, ['OpenMPI/1.6.4', 'GCC/4.7.2'])
Example #28
0
 def extra_options():
     extra_vars = {
         'buildtype': [None, "Specify the type of build (smpar: OpenMP, dmpar: MPI).", MANDATORY],
         'runtest': [True, "Build and run WPS tests", CUSTOM],
         'testdata': [None, "URL to test data required to run WPS test", CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #29
0
    def basic_options(self):
        """basic runtime options"""
        all_stops = [x[0] for x in EasyBlock.get_steps()]
        strictness_options = [run.IGNORE, run.WARN, run.ERROR]

        try:
            default_robot_path = get_paths_for("easyconfigs", robot_path=None)[0]
        except:
            self.log.warning("basic_options: unable to determine default easyconfig path")
            default_robot_path = False  # False as opposed to None, since None is used for indicating that --robot was not used

        descr = ("Basic options", "Basic runtime options for EasyBuild.")

        opts = OrderedDict({
            'dry-run': ("Print build overview incl. dependencies (full paths)", None, 'store_true', False),
            'dry-run-short': ("Print build overview incl. dependencies (short paths)", None, 'store_true', False, 'D'),
            'force': ("Force to rebuild software even if it's already installed (i.e. if it can be found as module)",
                      None, 'store_true', False, 'f'),
            'job': ("Submit the build as a job", None, 'store_true', False),
            'logtostdout': ("Redirect main log to stdout", None, 'store_true', False, 'l'),
            'only-blocks': ("Only build listed blocks", None, 'extend', None, 'b', {'metavar': 'BLOCKS'}),
            'robot': ("Path(s) to search for easyconfigs for missing dependencies (colon-separated)" ,
                      None, 'store_or_None', default_robot_path, 'r', {'metavar': 'PATH'}),
            'skip': ("Skip existing software (useful for installing additional packages)",
                     None, 'store_true', False, 'k'),
            'stop': ("Stop the installation after certain step", 'choice', 'store_or_None', 'source', 's', all_stops),
            'strict': ("Set strictness level", 'choice', 'store', run.WARN, strictness_options),
        })

        self.log.debug("basic_options: descr %s opts %s" % (descr, opts))
        self.add_group_parser(opts, descr)
    def basic_options(self):
        """basic runtime options"""
        all_stops = [x[0] for x in EasyBlock.get_steps()]
        strictness_options = [run.IGNORE, run.WARN, run.ERROR]

        descr = ("Basic options", "Basic runtime options for EasyBuild.")

        opts = OrderedDict({
            'dry-run': ("Print build overview incl. dependencies (full paths)", None, 'store_true', False),
            'dry-run-short': ("Print build overview incl. dependencies (short paths)", None, 'store_true', False, 'D'),
            'force': ("Force to rebuild software even if it's already installed (i.e. if it can be found as module)",
                      None, 'store_true', False, 'f'),
            'job': ("Submit the build as a job", None, 'store_true', False),
            'logtostdout': ("Redirect main log to stdout", None, 'store_true', False, 'l'),
            'only-blocks': ("Only build listed blocks", None, 'extend', None, 'b', {'metavar': 'BLOCKS'}),
            'robot': ("Enable dependency resolution, using easyconfigs in specified paths",
                      'pathlist', 'store_or_None', [], 'r', {'metavar': 'PATH[%sPATH]' % os.pathsep}),
            'robot-paths': ("Additional paths to consider by robot for easyconfigs (--robot paths get priority)",
                            'pathlist', 'add_flex', self.default_robot_paths, {'metavar': 'PATH[%sPATH]' % os.pathsep}),
            'skip': ("Skip existing software (useful for installing additional packages)",
                     None, 'store_true', False, 'k'),
            'stop': ("Stop the installation after certain step",
                     'choice', 'store_or_None', SOURCE_STEP, 's', all_stops),
            'strict': ("Set strictness level", 'choice', 'store', DEFAULT_STRICT, strictness_options),
        })

        self.log.debug("basic_options: descr %s opts %s" % (descr, opts))
        self.add_group_parser(opts, descr)
Example #31
0
 def extra_options():
     extra_vars = {
         'java_options': [
             '-Xmx256m',
             "$_JAVA_OPTIONS value set for install and in module file.",
             CUSTOM
         ],
     }
     return EasyBlock.extra_options(extra_vars)
Example #32
0
 def extra_options():
     """Custom easyconfig parameters for NEMO."""
     extra_vars = {
         'with_components':
         [None, "List of components to include (e.g. TOP_SRC)", MANDATORY],
         'add_keys': [None, "Add compilation keys", CUSTOM],
         'del_keys': [None, "Delete compilation keys", CUSTOM]
     }
     return EasyBlock.extra_options(extra_vars)
def process_easyconfig(path, onlyBlocks=None, regtest_online=False, validate=True):
    """
    Process easyconfig, returning some information for each block
    """
    blocks = retrieve_blocks_in_spec(path, onlyBlocks)

    easyconfigs = []
    for spec in blocks:
        # process for dependencies and real installversionname
        # - use mod? __init__ and importCfg are ignored.
        _log.debug("Processing easyconfig %s" % spec)

        # create easyconfig
        try:
            all_stops = [x[0] for x in EasyBlock.get_steps()]
            ec = EasyConfig(spec, validate=validate, valid_module_classes=module_classes(), valid_stops=all_stops)
        except EasyBuildError, err:
            msg = "Failed to process easyconfig %s:\n%s" % (spec, err.msg)
            _log.exception(msg)

        name = ec['name']

        # this app will appear as following module in the list
        easyconfig = {
            'spec': spec,
            'module': (ec.name, ec.get_installversion()),
            'dependencies': [],
            'builddependencies': [],
        }
        if len(blocks) > 1:
            easyconfig['originalSpec'] = path

        # add build dependencies
        for dep in ec.builddependencies():
            deptup = (dep['name'], dep['tc'])
            _log.debug("Adding build dependency %s for app %s." % (deptup, name))
            easyconfig['builddependencies'].append(deptup)

        # add dependencies (including build dependencies)
        for dep in ec.dependencies():
            deptup = (dep['name'], dep['tc'])
            _log.debug("Adding dependency %s for app %s." % (deptup, name))
            easyconfig['dependencies'].append(deptup)

        # add toolchain as dependency too
        if ec.toolchain.name != 'dummy':
            dep = (ec.toolchain.name, ec.toolchain.version)
            _log.debug("Adding toolchain %s as dependency for app %s." % (dep, name))
            easyconfig['dependencies'].append(dep)

        del ec

        # this is used by the parallel builder
        easyconfig['unresolvedDependencies'] = copy.copy(easyconfig['dependencies'])

        easyconfigs.append(easyconfig)
class EasyConfigTest(TestCase):
    """Baseclass for easyconfig testcases."""

    # initialize configuration (required for e.g. default modules_tool setting)
    eb_go = eboptions.parse_options()
    config.init(eb_go.options, eb_go.get_options_by_section('config'))
    build_options = {
        'check_osdeps': False,
        'force': True,
        'robot_path': get_paths_for("easyconfigs")[0],
        'suffix_modules_path': GENERAL_CLASS,
        'valid_module_classes': config.module_classes(),
        'valid_stops': [x[0] for x in EasyBlock.get_steps()],
    }
    config.init_build_options(build_options=build_options)
    config.set_tmpdir()
    del eb_go

    log = fancylogger.getLogger("EasyConfigTest", fname=False)
    # make sure a logger is present for main
    main._log = log
    ordered_specs = None
    parsed_easyconfigs = []

    def process_all_easyconfigs(self):
        """Process all easyconfigs and resolve inter-easyconfig dependencies."""
        # all available easyconfig files
        easyconfigs_path = get_paths_for("easyconfigs")[0]
        specs = glob.glob('%s/*/*/*.eb' % easyconfigs_path)

        # parse all easyconfigs if they haven't been already
        if not self.parsed_easyconfigs:
            for spec in specs:
                self.parsed_easyconfigs.extend(process_easyconfig(spec))

        self.ordered_specs = resolve_dependencies(self.parsed_easyconfigs)

    def test_dep_graph(self):
        """Unit test that builds a full dependency graph."""
        # pygraph dependencies required for constructing dependency graph are not available prior to Python 2.6
        if LooseVersion(
                sys.version) >= LooseVersion('2.6') and single_tests_ok:
            # temporary file for dep graph
            (hn, fn) = tempfile.mkstemp(suffix='.dot')
            os.close(hn)

            if self.ordered_specs is None:
                self.process_all_easyconfigs()

            dep_graph(fn, self.ordered_specs, silent=True)

            try:
                os.remove(fn)
            except OSError, err:
                log.error("Failed to remove %s: %s" % (fn, err))
        else:
Example #35
0
 def extra_options():
     """Define custom easyconfig parameters for GAMESS-US."""
     extra_vars = {
         'ddi_comm': ['mpi', "DDI communication layer to use", CUSTOM],
         'maxcpus': [None, "Maximum number of cores per node", MANDATORY],
         'maxnodes': [None, "Maximum number of nodes", MANDATORY],
         'runtest': [True, "Run GAMESS-US tests", CUSTOM],
         'scratch_dir': ['$TMPDIR', "Scratch dir to be used in rungms script", CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #36
0
 def extra_options(more_extra_vars=None):
     """Custom easyconfig parameters for foo."""
     if more_extra_vars is None:
         more_extra_vars = {}
     extra_vars = {
         'foo_extra1': [None, "first foo-specific easyconfig parameter (mandatory)", MANDATORY],
         'foo_extra2': ['FOO', "second foo-specific easyconfig parameter", CUSTOM],
     }
     extra_vars.update(more_extra_vars)
     return EasyBlock.extra_options(extra_vars)
Example #37
0
    def extra_options():
        """Custom easyconfig parameters for Trinity."""

        extra_vars = [
            ('withsampledata', [False, "Include sample data", CUSTOM]),
            ('bwapluginver', [None, "BWA pugin version", CUSTOM]),
            ('RSEMmod', [False, "Enable RSEMmod", CUSTOM]),
        ]

        return EasyBlock.extra_options(extra_vars)
 def extra_options():
     """Custom easyconfig parameters for WRF-Fire."""
     extra_vars = {
         'buildtype': [
             None, "Specify the type of build (serial, smpar (OpenMP), "
             "dmpar (MPI), dm+sm (hybrid OpenMP/MPI)).", MANDATORY
         ],
         'runtest': [True, "Build and run WRF tests", CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #39
0
    def sanity_check_step(self,
                          exts_filter=None,
                          custom_paths=None,
                          custom_commands=None):
        """
        Custom sanity check for extensions, whether installed as stand-alone module or not
        """
        if not self.cfg['exts_filter']:
            self.cfg['exts_filter'] = exts_filter
        self.log.debug("starting sanity check for extension with filter %s",
                       self.cfg['exts_filter'])

        if not self.is_extension:
            # load fake module
            fake_mod_data = self.load_fake_module(purge=True)

        # perform sanity check
        sanity_check_ok = Extension.sanity_check_step(self)

        if not self.is_extension:
            # unload fake module and clean up
            self.clean_up_fake_module(fake_mod_data)

        if custom_paths or self.cfg[
                'sanity_check_paths'] or custom_commands or self.cfg[
                    'sanity_check_commands']:
            EasyBlock.sanity_check_step(self,
                                        custom_paths=custom_paths,
                                        custom_commands=custom_commands,
                                        extension=self.is_extension)

        # pass or fail sanity check
        if not sanity_check_ok:
            msg = "Sanity check for %s failed: %s" % (self.name, '; '.join(
                self.sanity_check_fail_msgs))
            if self.is_extension:
                self.log.warning(msg)
            else:
                raise EasyBuildError(msg)
            return False
        else:
            self.log.info("Sanity check for %s successful!" % self.name)
            return True
Example #40
0
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to EB_jhbuild."""
     extra_vars = EasyBlock.extra_options(extra=extra_vars)
     extra_vars.update({
         'jhbuildrc_file': [
             'jhbuildrc', "File that contains the jhbuild configuration",
             CUSTOM
         ],
     })
     return extra_vars
Example #41
0
 def extra_options():
     extra_vars = {
         'buildtype': [
             None, "Specify the type of build (serial, smpar (OpenMP), "
             "dmpar (MPI), dm+sm (hybrid OpenMP/MPI)).", MANDATORY
         ],
         'rewriteopts': [True, "Replace -O3 with CFLAGS/FFLAGS", CUSTOM],
         'runtest': [True, "Build and run WRF tests", CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #42
0
    def setUp(self):
        """Set up everything for running a unit test."""
        super(EasyConfigTest, self).setUp()

        self.cwd = os.getcwd()
        self.all_stops = [x[0] for x in EasyBlock.get_steps()]
        if os.path.exists(self.eb_file):
            os.remove(self.eb_file)

        self.orig_current_version = easybuild.tools.build_log.CURRENT_VERSION
Example #43
0
 def extra_options():
     """Define custom easyconfig parameters for Molpro."""
     # Combine extra variables from Binary and ConfigureMake easyblocks as
     # well as those needed for Molpro specifically
     extra_vars = Binary.extra_options()
     extra_vars = ConfigureMake.extra_options(extra_vars)
     extra_vars.update({
         'precompiled_binaries': [False, "Are we installing precompiled binaries?", CUSTOM],
     })
     return EasyBlock.extra_options(extra_vars)
Example #44
0
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to Binary easyblock."""
     extra_vars = EasyBlock.extra_options(extra_vars)
     extra_vars.update({
         'extract_sources': [False, "Whether or not to extract sources", CUSTOM],
         'install_cmd': [None, "Install command to be used.", CUSTOM],
         # staged installation can help with the hard (potentially faulty) check on available disk space
         'staged_install': [False, "Perform staged installation via subdirectory of build directory", CUSTOM],
     })
     return extra_vars
Example #45
0
    def test_make_module_extend_modpath(self):
        """Test for make_module_extend_modpath"""
        self.contents = '\n'.join([
            'easyblock = "ConfigureMake"',
            'name = "pi"',
            'version = "3.14"',
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            'toolchain = {"name":"dummy", "version": "dummy"}',
            'moduleclass = "compiler"',
        ])
        self.writeEC()
        eb = EasyBlock(EasyConfig(self.eb_file))
        eb.installdir = config.install_path()

        # no $MODULEPATH extensions for default module naming scheme (EasyBuildMNS)
        self.assertEqual(eb.make_module_extend_modpath(), '')

        usermodsdir = 'my/own/modules'
        modclasses = ['compiler', 'tools']
        os.environ['EASYBUILD_MODULE_NAMING_SCHEME'] = 'CategorizedHMNS'
        build_options = {
            'subdir_user_modules': usermodsdir,
            'valid_module_classes': modclasses,
        }
        init_config(build_options=build_options)
        eb = EasyBlock(EasyConfig(self.eb_file))
        eb.installdir = config.install_path()

        txt = eb.make_module_extend_modpath()
        if get_module_syntax() == 'Tcl':
            regexs = [r'^module use ".*/modules/all/Compiler/pi/3.14/%s"$' % c for c in modclasses]
            home = r'\$env\(HOME\)'
            regexs.extend([
                # extension for user modules is guarded
                r'if { \[ file isdirectory \[ file join %s "%s/Compiler/pi/3.14" \] \] } {$' % (home, usermodsdir),
                # no per-moduleclass extension for user modules
                r'^\s+module use \[ file join %s "%s/Compiler/pi/3.14"\ ]$' % (home, usermodsdir),
            ])
        elif get_module_syntax() == 'Lua':
            regexs = [r'^prepend_path\("MODULEPATH", ".*/modules/all/Compiler/pi/3.14/%s"\)$' % c for c in modclasses]
            home = r'os.getenv\("HOME"\)'
            regexs.extend([
                # extension for user modules is guarded
                r'if isDir\(pathJoin\(%s, "%s/Compiler/pi/3.14"\)\) then' % (home, usermodsdir),
                # no per-moduleclass extension for user modules
                r'\s+prepend_path\("MODULEPATH", pathJoin\(%s, "%s/Compiler/pi/3.14"\)\)' % (home, usermodsdir),
            ])
        else:
            self.assertTrue(False, "Unknown module syntax: %s" % get_module_syntax())
        for regex in regexs:
            regex = re.compile(regex, re.M)
            self.assertTrue(regex.search(txt), "Pattern '%s' found in: %s" % (regex.pattern, txt))
Example #46
0
 def extra_options():
     """Custom easyconfig parameters for MCR."""
     extra_vars = {
         'java_options': [
             '-Xmx256m',
             "$_JAVA_OPTIONS value set for install and in module file.",
             CUSTOM
         ],
     }
     return EasyBlock.extra_options(extra_vars)
Example #47
0
 def test_buildininstalldir(self):
     """Test specifying build in install dir."""
     self.contents = '\n'.join([
         'name = "pi"',
         'version = "3.14"',
         'homepage = "http://example.com"',
         'description = "test easyconfig"',
         'toolchain = {"name": "dummy", "version": "dummy"}',
         'buildininstalldir = True',
     ])
     self.prep()
     ec = EasyConfig(self.eb_file)
     eb = EasyBlock(ec)
     eb.gen_builddir()
     eb.gen_installdir()
     eb.make_builddir()
     eb.make_installdir()
     self.assertEqual(eb.builddir, eb.installdir)
     self.assertTrue(os.path.isdir(eb.builddir))
Example #48
0
 def extra_options():
     """Custom easyconfig parameters for bar."""
     extra_vars = {
         'bar_extra1': [
             None, "first bar-specific easyconfig parameter (mandatory)",
             MANDATORY
         ],
         'bar_extra2':
         ['BAR', "second bar-specific easyconfig parameter", CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #49
0
    def run(self, unpack_src=False):
        """Common operations for extensions: unpacking sources, patching, ..."""

        # unpack file if desired
        if unpack_src:
            targetdir = os.path.join(self.master.builddir, remove_unwanted_chars(self.name))
            self.ext_dir = extract_file(self.src, targetdir, extra_options=self.unpack_options,
                                        change_into_dir=False, cmd=self.src_extract_cmd)

            # setting start dir must be done from unpacked source directory for extension,
            # because start_dir value is usually a relative path (if it is set)
            change_dir(self.ext_dir)

            self._set_start_dir()
            change_dir(self.start_dir)
        else:
            self._set_start_dir()

        # patch if needed
        EasyBlock.patch_step(self, beginpath=self.ext_dir)
Example #50
0
 def extra_options():
     extra_vars = {
         'compilerstr':[None, "Compiler string (gnu/intel/pgi).",MANDATORY],
         'build_mpi_parts':[False, "Build MPI parallelized parts", CUSTOM],
         'build_openmp_parts':[False, "Build OpenMP parts",CUSTOM],
         'build_cuda_parts':[False,"Build CUDA accelerated parts",CUSTOM],
         'amber_python_exe':[None, "Path to the python execuable to be forwarded to AMBER. This could be different from what easybuild is using.", CUSTOM],
         'skip_patches':[False,"Skip downloading and applying patches",CUSTOM],
         'runtest':[False,"Whether to run tests after build",CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #51
0
    def __init__(self, *args, **kwargs):
        """Initialize either as EasyBlock or as Extension."""

        self.is_extension = False

        if isinstance(args[0], EasyBlock):
            Extension.__init__(self, *args, **kwargs)
            # name and version properties of EasyBlock are used, so make sure name and version are correct
            self.cfg['name'] = self.ext.get('name', None)
            self.cfg['version'] = self.ext.get('version', None)
            self.builddir = self.master.builddir
            self.installdir = self.master.installdir
            self.is_extension = True
            self.unpack_options = None
        else:
            EasyBlock.__init__(self, *args, **kwargs)
            self.options = copy.deepcopy(self.cfg.get(
                'options', {}))  # we need this for Extension.sanity_check_step

        self.ext_dir = None  # dir where extension source was unpacked
Example #52
0
    def extra_options(extra_vars=None):
        """Extra easyconfig parameters specific to ExtensionEasyBlock."""

        # using [] as default value is a bad idea, so we handle it this way
        if extra_vars is None:
            extra_vars = []

        extra_vars.extend([
            ('options', [{}, "Dictionary with extension options.", CUSTOM]),
        ])
        return EasyBlock.extra_options(extra_vars)
Example #53
0
 def configure_step(self, name=None):
     """Configure build of toy."""
     if name is None:
         name = self.name
     # make sure Python system dep is handled correctly when specified
     if self.cfg['allow_system_deps']:
         if get_software_root('Python') != 'Python' or get_software_version(
                 'Python') != platform.python_version():
             raise EasyBlock(
                 "Sanity check on allowed Python system dep failed.")
     os.rename('%s.source' % name, '%s.c' % name)
Example #54
0
 def extra_options():
     """Add extra easyconfig parameters for Boost."""
     extra_vars = {
         'boost_mpi': [False, "Build mpi boost module", CUSTOM],
         'toolset': [
             None,
             "Toolset to use for Boost configuration ('--with-toolset for bootstrap.sh')",
             CUSTOM
         ],
     }
     return EasyBlock.extra_options(extra_vars)
Example #55
0
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to RPMs."""
     extra_vars = EasyBlock.extra_options(extra_vars)
     extra_vars.update({
         'force': [False, "Use force", CUSTOM],
         'preinstall': [False, "Enable pre install", CUSTOM],
         'postinstall': [False, "Enable post install", CUSTOM],
         'makesymlinks': [[], "Create symlinks for listed paths",
                          CUSTOM],  # supports glob
     })
     return extra_vars
Example #56
0
    def extra_options():
        testdata_urls = ["http://www.wien2k.at/reg_user/benchmark/test_case.tar.gz",
                         "http://www.wien2k.at/reg_user/benchmark/mpi-benchmark.tar.gz"]

        extra_vars = {
            'runtest': [True, "Run WIEN2k tests", CUSTOM],
            'testdata': [testdata_urls, "test data URL for WIEN2k benchmark test", CUSTOM],
            'wien_mpirun': [None, "MPI wrapper comand to use", CUSTOM],
            'remote': [None, "Remote command to use (e.g. pbsssh, ...)", CUSTOM],
        }
        return EasyBlock.extra_options(extra_vars)
Example #57
0
 def check_start_dir(expected_start_dir):
     """Check start dir."""
     eb = EasyBlock(ec['ec'])
     eb.silent = True
     eb.cfg['stop'] = 'patch'
     eb.run_all_steps(False)
     eb.guess_start_dir()
     abs_expected_start_dir = os.path.join(eb.builddir,
                                           expected_start_dir)
     self.assertTrue(
         os.path.samefile(eb.cfg['start_dir'], abs_expected_start_dir))
     self.assertTrue(
         os.path.samefile(os.getcwd(), abs_expected_start_dir))
Example #58
0
 def extra_options():
     """Add extra easyconfig parameters for Boost."""
     extra_vars = {
         'boost_mpi': [False, "Build mpi boost module", CUSTOM],
         'boost_multi_thread': [False, "Build boost with multi-thread option", CUSTOM],
         'toolset': [None, "Toolset to use for Boost configuration ('--with-toolset for bootstrap.sh')", CUSTOM],
         'mpi_launcher': [None, "Launcher to use when running MPI regression tests", CUSTOM],
         'only_python_bindings': [False, "Only install Boost.Python library providing Python bindings", CUSTOM],
         'use_glibcxx11_abi': [None, "Use the GLIBCXX11 ABI", CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #59
0
 def extra_options():
     extra_vars = {
         'buildtype': [
             None, "Specify the type of build (smpar: OpenMP, dmpar: MPI).",
             MANDATORY
         ],
         'runtest': [True, "Build and run WPS tests", CUSTOM],
         'testdata':
         [None, "URL to test data required to run WPS test", CUSTOM],
     }
     return EasyBlock.extra_options(extra_vars)
Example #60
0
    def extra_options():
        testdata_urls = [
                         "http://www.mmm.ucar.edu/wrf/src/data/avn_data.tar.gz",
                         "http://www.mmm.ucar.edu/wrf/src/wps_files/geog.tar.gz" # 697MB download, 16GB unpacked!
                        ]

        extra_vars = [
                      ('buildtype', [None, "Specify the type of build (smpar: OpenMP, dmpar: MPI).", MANDATORY]),
                      ('runtest', [True, "Build and run WPS tests (default: True).", CUSTOM]),
                      ('testdata', [testdata_urls, "URL to test data required to run WPS test (default: %s)." % testdata_urls, CUSTOM])
                     ]
        return EasyBlock.extra_options(extra_vars)