Exemple #1
0
    def run(self):
        """Perform the actual Perl module build/installation procedure"""

        if not self.src:
            raise EasyBuildError("No source found for Perl module %s, required for installation. (src: %s)",
                                 self.name, self.src)
        ExtensionEasyBlock.run(self, unpack_src=True)

        self.install_perl_module()
 def extra_options(extra_vars=None):
     """Easyconfig parameters specific to Python packages."""
     if extra_vars is None:
         extra_vars = {}
     extra_vars.update({
         'unpack_sources':
         [True, "Unpack sources prior to build/install", CUSTOM],
         'req_py_majver': [
             2,
             "Required major Python version (only relevant when using system Python)",
             CUSTOM
         ],
         'req_py_minver': [
             6,
             "Required minor Python version (only relevant when using system Python)",
             CUSTOM
         ],
         'runtest': [True, "Run unit tests.", CUSTOM],  # overrides default
         'use_easy_install':
         [False,
          "Install using '%s'" % EASY_INSTALL_INSTALL_CMD, CUSTOM],
         'use_pip': [False,
                     "Install using '%s'" % PIP_INSTALL_CMD, CUSTOM],
         'use_setup_py_develop':
         [False, "Install using '%s'" % SETUP_PY_DEVELOP_CMD, CUSTOM],
         'zipped_egg': [
             False, "Install as a zipped eggs (requires use_easy_install)",
             CUSTOM
         ],
     })
     return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to RPackage."""
     extra_vars = ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
     extra_vars.update({
         'unpack_sources': [False, "Unpack sources before installation", CUSTOM],
     })
     return extra_vars
 def sanity_check_step(self, *args, **kwargs):
     """
     Custom sanity check for Perl modules
     """
     return ExtensionEasyBlock.sanity_check_step(self,
                                                 EXTS_FILTER_PERL_MODULES,
                                                 *args, **kwargs)
 def extra_options():
     """Easyconfig parameters specific to Perl modules."""
     extra_vars = {
         'runtest': ['test', "Run unit tests.",
                     CUSTOM],  # overrides default
     }
     return ExtensionEasyBlock.extra_options(extra_vars)
Exemple #6
0
 def extra_options(extra_vars=None):
     """Easyconfig parameters specific to Python packages."""
     if extra_vars is None:
         extra_vars = {}
     extra_vars.update({
         'buildcmd': ['build', "Command to pass to setup.py to build the extension", CUSTOM],
         'check_ldshared': [None, 'Check Python value of $LDSHARED, correct if needed to "$CC -shared"', CUSTOM],
         'download_dep_fail': [None, "Fail if downloaded dependencies are detected", CUSTOM],
         'install_target': ['install', "Option to pass to setup.py", CUSTOM],
         'pip_ignore_installed': [True, "Let pip ignore installed Python packages (i.e. don't remove them)", CUSTOM],
         'req_py_majver': [None, "Required major Python version (only relevant when using system Python)", CUSTOM],
         'req_py_minver': [None, "Required minor Python version (only relevant when using system Python)", CUSTOM],
         'sanity_pip_check': [False, "Run 'pip check' to ensure all required Python packages are installed", CUSTOM],
         'runtest': [True, "Run unit tests.", CUSTOM],  # overrides default
         'unpack_sources': [True, "Unpack sources prior to build/install", CUSTOM],
         'use_easy_install': [False, "Install using '%s' (deprecated)" % EASY_INSTALL_INSTALL_CMD, CUSTOM],
         'use_pip': [None, "Install using '%s'" % PIP_INSTALL_CMD, CUSTOM],
         'use_pip_editable': [False, "Install using 'pip install --editable'", CUSTOM],
         # see https://packaging.python.org/tutorials/installing-packages/#installing-setuptools-extras
         'use_pip_extras': [None, "String with comma-separated list of 'extras' to install via pip", CUSTOM],
         'use_pip_for_deps': [False, "Install dependencies using '%s'" % PIP_INSTALL_CMD, CUSTOM],
         'use_pip_requirement': [False, "Install using 'pip install --requirement'. The sources is expected " +
                                        "to be the requirements file.", CUSTOM],
         'use_setup_py_develop': [False, "Install using '%s' (deprecated)" % SETUP_PY_DEVELOP_CMD, CUSTOM],
         'zipped_egg': [False, "Install as a zipped eggs (requires use_easy_install)", CUSTOM],
     })
     return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
 def extra_options():
     """Easyconfig parameters specific to Python packages."""
     extra_vars = [
         ('runtest', [True, "Run unit tests.",
                      CUSTOM]),  # overrides default
     ]
     return ExtensionEasyBlock.extra_options(extra_vars)
Exemple #8
0
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to RubyGem easyblock."""
     extra_vars = ExtensionEasyBlock.extra_options(extra_vars)
     extra_vars.update({
         'gem_file': [None, "Path to gem file in unpacked sources", CUSTOM],
     })
     return extra_vars
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to RPackage."""
     extra_vars = ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
     extra_vars.update({
         'unpack_sources':
         [False, "Unpack sources before installation", CUSTOM],
     })
     return extra_vars
Exemple #10
0
    def extra_options(extra_vars=None):
        """Custom easyconfig parameters for toytoy."""
        if extra_vars is None:
            extra_vars = {}

        extra_vars['make_module'] = [True, "Skip generating (final) module file", CUSTOM]

        return ExtensionEasyBlock.extra_options(extra_vars)
 def make_module_extra(self):
     """Add install path to PERL*LIB"""
     majver = get_major_perl_version()
     sitearchsuffix = get_sitearch_suffix()
     # also add sitearch dir to Perl search path
     txt = self.moduleGenerator.prepend_paths("PERL%sLIB" % majver,
                                              ['', sitearchsuffix])
     return ExtensionEasyBlock.make_module_extra(self, txt)
    def extra_options(extra_vars=None):
        if extra_vars is None:
            extra_vars = {}

        extra_vars.update({
            'arch_name': [None, "Change julia's Project.toml pathname", CUSTOM],
        })
        return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
Exemple #13
0
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to RPackage."""
     extra_vars = ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
     extra_vars.update({
         'exts_subdir': ['', "Subdirectory where R extensions should be installed info", CUSTOM],
         'unpack_sources': [False, "Unpack sources before installation", CUSTOM],
     })
     return extra_vars
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to RPackage."""
     extra_vars = ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
     extra_vars.update({
         'exts_subdir': ['', "Subdirectory where R extensions should be installed info", CUSTOM],
         'unpack_sources': [False, "Unpack sources before installation", CUSTOM],
     })
     return extra_vars
Exemple #15
0
    def extra_options(extra_vars=None):
        if extra_vars is None:
            extra_vars = {}

        extra_vars.update({
            'arch_name': [None, "Change julia's Project.toml pathname", CUSTOM],
            'mpiexec':  [None, "Set the mpiexec command", CUSTOM],
            'mpiexec_args':  [None, "Set the mpiexec command args", CUSTOM],
        })
        return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
Exemple #16
0
 def extra_options(extra_vars=None):
     """Easyconfig parameters specific to Python packages."""
     if extra_vars is None:
         extra_vars = {}
     extra_vars.update({
         'runtest': [True, "Run unit tests.", CUSTOM],  # overrides default
         'use_easy_install': [False, "Install using '%s'" % EASY_INSTALL_CMD, CUSTOM],
         'zipped_egg': [False, "Install as a zipped eggs (requires use_easy_install)", CUSTOM],
     })
     return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
Exemple #17
0
 def extra_options(extra_vars=None):
     """Easyconfig parameters specific to Python packages."""
     if extra_vars is None:
         extra_vars = {}
     extra_vars.update({
         'buildcmd': [
             'build', "Command to pass to setup.py to build the extension",
             CUSTOM
         ],
         'check_ldshared': [
             False,
             'Check Python value of $LDSHARED, correct if needed to "$CC -shared"',
             CUSTOM
         ],
         'download_dep_fail':
         [None, "Fail if downloaded dependencies are detected", CUSTOM],
         'install_target':
         ['install', "Option to pass to setup.py", CUSTOM],
         'req_py_majver': [
             2,
             "Required major Python version (only relevant when using system Python)",
             CUSTOM
         ],
         'req_py_minver': [
             6,
             "Required minor Python version (only relevant when using system Python)",
             CUSTOM
         ],
         'runtest': [True, "Run unit tests.", CUSTOM],  # overrides default
         'unpack_sources':
         [True, "Unpack sources prior to build/install", CUSTOM],
         'use_easy_install': [
             False,
             "Install using '%s' (deprecated)" % EASY_INSTALL_INSTALL_CMD,
             CUSTOM
         ],
         'use_pip': [False,
                     "Install using '%s'" % PIP_INSTALL_CMD, CUSTOM],
         'use_pip_editable':
         [False, "Install using 'pip install --editable'", CUSTOM],
         'use_pip_for_deps': [
             False,
             "Install dependencies using '%s'" % PIP_INSTALL_CMD, CUSTOM
         ],
         'use_setup_py_develop': [
             False,
             "Install using '%s' (deprecated)" % SETUP_PY_DEVELOP_CMD,
             CUSTOM
         ],
         'zipped_egg': [
             False, "Install as a zipped eggs (requires use_easy_install)",
             CUSTOM
         ],
     })
     return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
 def extra_options(extra_vars=None):
     """Easyconfig parameters specific to Python packages."""
     if extra_vars is None:
         extra_vars = {}
     extra_vars.update({
         'unpack_sources': [True, "Unpack sources prior to build/install", CUSTOM],
         'req_py_majver': [2, "Required major Python version (only relevant when using system Python)", CUSTOM],
         'req_py_minver': [6, "Required minor Python version (only relevant when using system Python)", CUSTOM],
         'runtest': [True, "Run unit tests.", CUSTOM],  # overrides default
         'use_easy_install': [False, "Install using '%s'" % EASY_INSTALL_INSTALL_CMD, CUSTOM],
         'use_pip': [False, "Install using '%s'" % PIP_INSTALL_CMD, CUSTOM],
         'zipped_egg': [False, "Install as a zipped eggs (requires use_easy_install)", CUSTOM],
     })
     return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
Exemple #19
0
 def extra_options(extra_vars=None):
     """Extra easyconfig parameters specific to Tarball."""
     extra_vars = ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
     extra_vars.update({
         'install_type': [
             None,
             "Defaults to extract tarball into clean directory. Options: 'merge' merges tarball "
             "to existing directory, 'subdir' extracts tarball into its own sub-directory",
             CUSTOM
         ],
         'preinstall_cmd':
         [None, "Command to execute before installation", CUSTOM],
     })
     return extra_vars
 def extra_options(extra_vars=None):
     """Easyconfig parameters specific to Python packages."""
     if extra_vars is None:
         extra_vars = {}
     extra_vars.update({
         'unpack_sources': [True, "Unpack sources prior to build/install", CUSTOM],
         'req_py_majver': [2, "Required major Python version (only relevant when using system Python)", CUSTOM],
         'req_py_minver': [6, "Required minor Python version (only relevant when using system Python)", CUSTOM],
         'runtest': [True, "Run unit tests.", CUSTOM],  # overrides default
         'use_easy_install': [False, "Install using '%s' (deprecated)" % EASY_INSTALL_INSTALL_CMD, CUSTOM],
         'use_pip': [False, "Install using '%s'" % PIP_INSTALL_CMD, CUSTOM],
         'use_pip_for_deps': [False, "Install dependencies using '%s'" % PIP_INSTALL_CMD, CUSTOM],
         'use_setup_py_develop': [False, "Install using '%s' (deprecated)" % SETUP_PY_DEVELOP_CMD, CUSTOM],
         'zipped_egg': [False, "Install as a zipped eggs (requires use_easy_install)", CUSTOM],
         'buildcmd': ['build', "Command to pass to setup.py to build the extension", CUSTOM],
         'install_target': ['install', "Option to pass to setup.py", CUSTOM],
     })
     return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
 def make_module_extra(self):
     """Add install path to PERL*LIB"""
     majver = self.version.split('.')[0]
     txt = self.moduleGenerator.prepend_paths("PERL%sLIB" % majver, [''])
     return ExtensionEasyBlock.make_module_extra(self, txt)
Exemple #22
0
 def extra_options():
     """Custom easyconfig parameters for toy extensions."""
     extra_vars = {
         'toy_ext_param': ['', "Toy extension parameter", CUSTOM],
     }
     return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
 def make_module_extra(self):
     """Add install path to PERL*LIB"""
     majver = self.version.split('.')[0]
     txt = self.moduleGenerator.prepend_paths("PERL%sLIB" % majver, [''])
     return ExtensionEasyBlock.make_module_extra(self, txt)
    def test_easyblock(self):
        """ make sure easyconfigs defining extensions work"""

        def check_extra_options_format(extra_options):
            """Make sure extra_options value is of correct format."""
            # EasyBuild v2.0: dict with <string> keys and <list> values
            # (breaks backward compatibility compared to v1.x)
            self.assertTrue(isinstance(extra_options, dict))  # conversion to a dict works
            extra_options.items()
            extra_options.keys()
            extra_options.values()
            for key in extra_options.keys():
                self.assertTrue(isinstance(extra_options[key], list))
                self.assertTrue(len(extra_options[key]), 3)

        name = "pi"
        version = "3.14"
        self.contents = '\n'.join([
            'easyblock = "ConfigureMake"',
            'name = "%s"' % name,
            'version = "%s"' % version,
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            'toolchain = {"name":"dummy", "version": "dummy"}',
            'exts_list = ["ext1"]',
        ])
        self.writeEC()
        stdoutorig = sys.stdout
        sys.stdout = open("/dev/null", 'w')
        ec = EasyConfig(self.eb_file)
        eb = EasyBlock(ec)
        self.assertEqual(eb.cfg['name'], name)
        self.assertEqual(eb.cfg['version'], version)
        self.assertRaises(NotImplementedError, eb.run_all_steps, True)
        check_extra_options_format(eb.extra_options())
        sys.stdout.close()
        sys.stdout = stdoutorig

        # check whether 'This is easyblock' log message is there
        tup = ('EasyBlock', 'easybuild.framework.easyblock', '.*easybuild/framework/easyblock.pyc*')
        eb_log_msg_re = re.compile(r"INFO This is easyblock %s from module %s (%s)" % tup, re.M)
        logtxt = read_file(eb.logfile)
        self.assertTrue(eb_log_msg_re.search(logtxt), "Pattern '%s' found in: %s" % (eb_log_msg_re.pattern, logtxt))

        # test extensioneasyblock, as extension
        exeb1 = ExtensionEasyBlock(eb, {'name': 'foo', 'version': '0.0'})
        self.assertEqual(exeb1.cfg['name'], 'foo')
        extra_options = exeb1.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in extra_options)

        # test extensioneasyblock, as easyblock
        exeb2 = ExtensionEasyBlock(ec)
        self.assertEqual(exeb2.cfg['name'], 'pi')
        self.assertEqual(exeb2.cfg['version'], '3.14')
        extra_options = exeb2.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in extra_options)

        class TestExtension(ExtensionEasyBlock):
            @staticmethod
            def extra_options():
                return ExtensionEasyBlock.extra_options({'extra_param': [None, "help", CUSTOM]})
        texeb = TestExtension(eb, {'name': 'bar'})
        self.assertEqual(texeb.cfg['name'], 'bar')
        extra_options = texeb.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in extra_options)
        self.assertEqual(extra_options['extra_param'], [None, "help", CUSTOM])

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
 def extra_options():
     return ExtensionEasyBlock.extra_options({'extra_param': [None, "help", CUSTOM]})
 def extra_options():
     """Custom easyconfig parameters for toy extensions."""
     extra_vars = {
         'toy_ext_param': ['', "Toy extension parameter", CUSTOM],
     }
     return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
Exemple #27
0
    def test_easyblock(self):
        """ make sure easyconfigs defining extensions work"""

        def check_extra_options_format(extra_options):
            """Make sure extra_options value is of correct format."""
            # EasyBuild v1.x: list of (<string>, <list>) tuples
            self.assertTrue(isinstance(list(extra_options), list))  # conversion to a list works
            for extra_option in extra_options:
                self.assertTrue(isinstance(extra_option, tuple))
                self.assertEqual(len(extra_option), 2)
                self.assertTrue(isinstance(extra_option[0], basestring))
                self.assertTrue(isinstance(extra_option[1], list))
                self.assertEqual(len(extra_option[1]), 3)
            # EasyBuild v2.0: dict with <string> keys and <list> values
            # (breaks backward compatibility compared to v1.x)
            self.assertTrue(isinstance(dict(extra_options), dict))  # conversion to a dict works
            extra_options.items()
            extra_options.keys()
            extra_options.values()
            for key in extra_options.keys():
                self.assertTrue(isinstance(extra_options[key], list))
                self.assertTrue(len(extra_options[key]), 3)

        name = "pi"
        version = "3.14"
        self.contents = "\n".join(
            [
                'name = "%s"' % name,
                'version = "%s"' % version,
                'homepage = "http://example.com"',
                'description = "test easyconfig"',
                'toolchain = {"name":"dummy", "version": "dummy"}',
                'exts_list = ["ext1"]',
            ]
        )
        self.writeEC()
        stdoutorig = sys.stdout
        sys.stdout = open("/dev/null", "w")
        ec = EasyConfig(self.eb_file)
        eb = EasyBlock(ec)
        self.assertEqual(eb.cfg["name"], name)
        self.assertEqual(eb.cfg["version"], version)
        self.assertRaises(NotImplementedError, eb.run_all_steps, True)
        check_extra_options_format(eb.extra_options())
        sys.stdout.close()
        sys.stdout = stdoutorig

        # check whether 'This is easyblock' log message is there
        tup = ("EasyBlock", "easybuild.framework.easyblock", ".*easybuild/framework/easyblock.pyc*")
        eb_log_msg_re = re.compile(r"INFO This is easyblock %s from module %s (%s)" % tup, re.M)
        logtxt = read_file(eb.logfile)
        self.assertTrue(eb_log_msg_re.search(logtxt), "Pattern '%s' found in: %s" % (eb_log_msg_re.pattern, logtxt))

        # test extensioneasyblock, as extension
        exeb1 = ExtensionEasyBlock(eb, {"name": "foo", "version": "0.0"})
        self.assertEqual(exeb1.cfg["name"], "foo")
        extra_options = exeb1.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue("options" in [key for (key, _) in extra_options])

        # test extensioneasyblock, as easyblock
        exeb2 = ExtensionEasyBlock(ec)
        self.assertEqual(exeb2.cfg["name"], "pi")
        self.assertEqual(exeb2.cfg["version"], "3.14")
        extra_options = exeb2.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue("options" in [key for (key, _) in extra_options])

        class TestExtension(ExtensionEasyBlock):
            @staticmethod
            def extra_options():
                return ExtensionEasyBlock.extra_options([("extra_param", [None, "help", CUSTOM])])

        texeb = TestExtension(eb, {"name": "bar"})
        self.assertEqual(texeb.cfg["name"], "bar")
        extra_options = texeb.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue("options" in [key for (key, _) in extra_options])
        self.assertEqual([val for (key, val) in extra_options if key == "extra_param"][0], [None, "help", CUSTOM])

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
Exemple #28
0
    def extra_options(extra_vars=None):
        """Easyconfig parameters specific to Python packages."""
        if extra_vars is None:
            extra_vars = {}
        extra_vars.update({
            'buildcmd': [
                None,
                "Command for building the package (e.g. for custom builds resulting in a whl file). "
                "When using setup.py this will be passed to setup.py and defaults to 'build'. "
                "Otherwise it will be used as-is. A value of None then skips the build step. "
                "The template %(python)s will be replace by the currently used Python binary.",
                CUSTOM
            ],
            'check_ldshared': [
                None,
                'Check Python value of $LDSHARED, correct if needed to "$CC -shared"',
                CUSTOM
            ],
            'download_dep_fail':
            [None, "Fail if downloaded dependencies are detected", CUSTOM],
            'install_src': [
                None,
                "Source path to pass to the install command (e.g. a whl file)."
                "Defaults to '.' for unpacked sources or the first source file specified",
                CUSTOM
            ],
            'install_target':
            ['install', "Option to pass to setup.py", CUSTOM],
            'pip_ignore_installed': [
                True,
                "Let pip ignore installed Python packages (i.e. don't remove them)",
                CUSTOM
            ],
            'pip_no_index': [
                None,
                "Pass --no-index to pip to disable connecting to PyPi entirely which also disables "
                "the pip version check. Enabled by default when pip_ignore_installed=True",
                CUSTOM
            ],
            'req_py_majver': [
                None,
                "Required major Python version (only relevant when using system Python)",
                CUSTOM
            ],
            'req_py_minver': [
                None,
                "Required minor Python version (only relevant when using system Python)",
                CUSTOM
            ],
            'sanity_pip_check': [
                False,
                "Run 'pip check' to ensure all required Python packages are installed "
                "and check for any package with an invalid (0.0.0) version.",
                CUSTOM
            ],
            'runtest': [True, "Run unit tests.", CUSTOM],  # overrides default
            'unpack_sources': [
                None,
                "Unpack sources prior to build/install. Defaults to 'True' except for whl files",
                CUSTOM
            ],
            # A version of 0.0.0 is usually an error on installation unless the package does really not provide a
            # version. Those would fail the (extended) sanity_pip_check. So as a last resort they can be added here
            # and will be excluded from that check. Note that the display name is required, i.e. from `pip list`.
            'unversioned_packages':
            [[],
             "List of packages that don't have a version at all, i.e. show 0.0.0",
             CUSTOM],
            'use_pip': [None,
                        "Install using '%s'" % PIP_INSTALL_CMD, CUSTOM],
            'use_pip_editable':
            [False, "Install using 'pip install --editable'", CUSTOM],
            # see https://packaging.python.org/tutorials/installing-packages/#installing-setuptools-extras
            'use_pip_extras': [
                None,
                "String with comma-separated list of 'extras' to install via pip",
                CUSTOM
            ],
            'use_pip_for_deps': [
                False,
                "Install dependencies using '%s'" % PIP_INSTALL_CMD, CUSTOM
            ],
            'use_pip_requirement': [
                False,
                "Install using 'pip install --requirement'. The sources is expected "
                + "to be the requirements file.", CUSTOM
            ],
            'zipped_egg': [False, "Install as a zipped eggs", CUSTOM],
        })
        # Use PYPI_SOURCE as the default for source_urls.
        # As PyPi ignores the casing in the path part of the URL (but not the filename) we can always use PYPI_SOURCE.
        if 'source_urls' not in extra_vars:
            # Create a copy so the defaults are not modified by the following line
            src_urls = DEFAULT_CONFIG['source_urls'][:]
            src_urls[0] = [
                url for name, url, _ in TEMPLATE_CONSTANTS
                if name == 'PYPI_SOURCE'
            ]
            extra_vars['source_urls'] = src_urls

        return ExtensionEasyBlock.extra_options(extra_vars=extra_vars)
 def extra_options():
     """Easyconfig parameters specific to Python packages."""
     extra_vars = [
         ('runtest', [True, "Run unit tests.", CUSTOM]),  # overrides default
     ]
     return ExtensionEasyBlock.extra_options(extra_vars)
 def extra_options():
     """Easyconfig parameters specific to Perl modules."""
     extra_vars = [("runtest", ["test", "Run unit tests.", CUSTOM])]  # overrides default
     return ExtensionEasyBlock.extra_options(extra_vars)
    def test_easyblock(self):
        """ make sure easyconfigs defining extensions work"""

        def check_extra_options_format(extra_options):
            """Make sure extra_options value is of correct format."""
            # EasyBuild v1.x
            self.assertTrue(isinstance(extra_options, list))
            for extra_option in extra_options:
                self.assertTrue(isinstance(extra_option, tuple))
                self.assertEqual(len(extra_option), 2)
                self.assertTrue(isinstance(extra_option[0], basestring))
                self.assertTrue(isinstance(extra_option[1], list))
                self.assertEqual(len(extra_option[1]), 3)
            # EasyBuild v2.0 (breaks backward compatibility compared to v1.x)
            #self.assertTrue(isinstance(extra_options, dict))
            #for key in extra_options:
            #    self.assertTrue(isinstance(extra_options[key], list))
            #    self.assertTrue(len(extra_options[key]), 3)

        name = "pi"
        version = "3.14"
        self.contents =  '\n'.join([
            'name = "%s"' % name,
            'version = "%s"' % version,
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            'toolchain = {"name":"dummy", "version": "dummy"}',
            'exts_list = ["ext1"]',
        ])
        self.writeEC()
        stdoutorig = sys.stdout
        sys.stdout = open("/dev/null", 'w')
        ec = EasyConfig(self.eb_file)
        eb = EasyBlock(ec)
        self.assertEqual(eb.cfg['name'], name)
        self.assertEqual(eb.cfg['version'], version)
        self.assertRaises(NotImplementedError, eb.run_all_steps, True)
        check_extra_options_format(eb.extra_options())
        sys.stdout.close()
        sys.stdout = stdoutorig

        # test extensioneasyblock, as extension
        exeb1 = ExtensionEasyBlock(eb, {'name': 'foo', 'version': '0.0'})
        self.assertEqual(exeb1.cfg['name'], 'foo')
        extra_options = exeb1.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in [key for (key, _) in extra_options])

        # test extensioneasyblock, as easyblock
        exeb2 = ExtensionEasyBlock(ec)
        self.assertEqual(exeb2.cfg['name'], 'pi')
        self.assertEqual(exeb2.cfg['version'], '3.14')
        extra_options = exeb2.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in [key for (key, _) in extra_options])

        class TestExtension(ExtensionEasyBlock):
            @staticmethod
            def extra_options():
                return ExtensionEasyBlock.extra_options([('extra_param', [None, "help", CUSTOM])])
        texeb = TestExtension(eb, {'name': 'bar'})
        self.assertEqual(texeb.cfg['name'], 'bar')
        extra_options = texeb.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in [key for (key, _) in extra_options])
        self.assertEqual([val for (key, val) in extra_options if key == 'extra_param'][0], [None, "help", CUSTOM])

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
 def extra_options():
     return ExtensionEasyBlock.extra_options([('extra_param', [None, "help", CUSTOM])])
Exemple #33
0
 def extra_options():
     return ExtensionEasyBlock.extra_options(
         {'extra_param': [None, "help", CUSTOM]})
Exemple #34
0
    def test_easyblock(self):
        """ make sure easyconfigs defining extensions work"""
        def check_extra_options_format(extra_options):
            """Make sure extra_options value is of correct format."""
            # EasyBuild v2.0: dict with <string> keys and <list> values
            # (breaks backward compatibility compared to v1.x)
            self.assertTrue(isinstance(extra_options,
                                       dict))  # conversion to a dict works
            extra_options.items()
            extra_options.keys()
            extra_options.values()
            for key in extra_options.keys():
                self.assertTrue(isinstance(extra_options[key], list))
                self.assertTrue(len(extra_options[key]), 3)

        name = "pi"
        version = "3.14"
        self.contents = '\n'.join([
            'easyblock = "ConfigureMake"',
            'name = "%s"' % name,
            'version = "%s"' % version,
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            'toolchain = {"name":"dummy", "version": "dummy"}',
            'exts_list = ["ext1"]',
        ])
        self.writeEC()
        stdoutorig = sys.stdout
        sys.stdout = open("/dev/null", 'w')
        ec = EasyConfig(self.eb_file)
        eb = EasyBlock(ec)
        self.assertEqual(eb.cfg['name'], name)
        self.assertEqual(eb.cfg['version'], version)
        self.assertRaises(NotImplementedError, eb.run_all_steps, True)
        check_extra_options_format(eb.extra_options())
        sys.stdout.close()
        sys.stdout = stdoutorig

        # check whether 'This is easyblock' log message is there
        tup = ('EasyBlock', 'easybuild.framework.easyblock',
               '.*easybuild/framework/easyblock.pyc*')
        eb_log_msg_re = re.compile(
            r"INFO This is easyblock %s from module %s (%s)" % tup, re.M)
        logtxt = read_file(eb.logfile)
        self.assertTrue(
            eb_log_msg_re.search(logtxt),
            "Pattern '%s' found in: %s" % (eb_log_msg_re.pattern, logtxt))

        # test extensioneasyblock, as extension
        exeb1 = ExtensionEasyBlock(eb, {'name': 'foo', 'version': '0.0'})
        self.assertEqual(exeb1.cfg['name'], 'foo')
        extra_options = exeb1.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in extra_options)

        # test extensioneasyblock, as easyblock
        exeb2 = ExtensionEasyBlock(ec)
        self.assertEqual(exeb2.cfg['name'], 'pi')
        self.assertEqual(exeb2.cfg['version'], '3.14')
        extra_options = exeb2.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in extra_options)

        class TestExtension(ExtensionEasyBlock):
            @staticmethod
            def extra_options():
                return ExtensionEasyBlock.extra_options(
                    {'extra_param': [None, "help", CUSTOM]})

        texeb = TestExtension(eb, {'name': 'bar'})
        self.assertEqual(texeb.cfg['name'], 'bar')
        extra_options = texeb.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in extra_options)
        self.assertEqual(extra_options['extra_param'], [None, "help", CUSTOM])

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
 def extra_options():
     """Easyconfig parameters specific to Perl modules."""
     extra_vars = {
         'runtest': ['test', "Run unit tests.", CUSTOM],  # overrides default
     }
     return ExtensionEasyBlock.extra_options(extra_vars)
    def test_easyblock(self):
        """ make sure easyconfigs defining extensions work"""

        def check_extra_options_format(extra_options):
            """Make sure extra_options value is of correct format."""
            # EasyBuild v1.x
            self.assertTrue(isinstance(extra_options, list))
            for extra_option in extra_options:
                self.assertTrue(isinstance(extra_option, tuple))
                self.assertEqual(len(extra_option), 2)
                self.assertTrue(isinstance(extra_option[0], basestring))
                self.assertTrue(isinstance(extra_option[1], list))
                self.assertEqual(len(extra_option[1]), 3)
            # EasyBuild v2.0 (breaks backward compatibility compared to v1.x)
            #self.assertTrue(isinstance(extra_options, dict))
            #for key in extra_options:
            #    self.assertTrue(isinstance(extra_options[key], list))
            #    self.assertTrue(len(extra_options[key]), 3)

        name = "pi"
        version = "3.14"
        self.contents =  '\n'.join([
            'name = "%s"' % name,
            'version = "%s"' % version,
            'homepage = "http://example.com"',
            'description = "test easyconfig"',
            'toolchain = {"name":"dummy", "version": "dummy"}',
            'exts_list = ["ext1"]',
        ])
        self.writeEC()
        stdoutorig = sys.stdout
        sys.stdout = open("/dev/null", 'w')
        ec = EasyConfig(self.eb_file)
        eb = EasyBlock(ec)
        self.assertEqual(eb.cfg['name'], name)
        self.assertEqual(eb.cfg['version'], version)
        self.assertRaises(NotImplementedError, eb.run_all_steps, True)
        check_extra_options_format(eb.extra_options())
        sys.stdout.close()
        sys.stdout = stdoutorig

        # test extensioneasyblock, as extension
        exeb1 = ExtensionEasyBlock(eb, {'name': 'foo', 'version': '0.0'})
        self.assertEqual(exeb1.cfg['name'], 'foo')
        extra_options = exeb1.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in [key for (key, _) in extra_options])

        # test extensioneasyblock, as easyblock
        exeb2 = ExtensionEasyBlock(ec)
        self.assertEqual(exeb2.cfg['name'], 'pi')
        self.assertEqual(exeb2.cfg['version'], '3.14')
        extra_options = exeb2.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in [key for (key, _) in extra_options])

        class TestExtension(ExtensionEasyBlock):
            @staticmethod
            def extra_options():
                return ExtensionEasyBlock.extra_options([('extra_param', [None, "help", CUSTOM])])
        texeb = TestExtension(eb, {'name': 'bar'})
        self.assertEqual(texeb.cfg['name'], 'bar')
        extra_options = texeb.extra_options()
        check_extra_options_format(extra_options)
        self.assertTrue('options' in [key for (key, _) in extra_options])
        self.assertEqual([val for (key, val) in extra_options if key == 'extra_param'][0], [None, "help", CUSTOM])

        # cleanup
        eb.close_log()
        os.remove(eb.logfile)
 def sanity_check_step(self, *args, **kwargs):
     """
     Custom sanity check for Perl modules
     """
     return ExtensionEasyBlock.sanity_check_step(self, EXTS_FILTER_PERL_MODULES, *args, **kwargs)
 def extra_options():
     return ExtensionEasyBlock.extra_options([('extra_param', [None, "help", CUSTOM])])