def prepare_step(self, *args, **kwargs):
     """Do the bundle prepare step to ensure any deps are loaded at a minimum."""
     if self.cfg['generate_standalone_module']:
         if self.cfg['name'] in ['GCC', 'GCCcore']:
             EB_GCC.prepare_step(self, *args, **kwargs)
         elif self.cfg['name'] in ['icc']:
             EB_icc.prepare_step(self, *args, **kwargs)
         elif self.cfg['name'] in ['ifort']:
             EB_ifort.prepare_step(self, *args, **kwargs)
         else:
             raise EasyBuildError(
                 "I don't know how to do the prepare_step for %s",
                 self.cfg['name'])
     else:
         Bundle.prepare_step(self, *args, **kwargs)
 def make_module_extra(self, *args, **kwargs):
     """Add any additional module text."""
     if self.cfg['generate_standalone_module']:
         if self.cfg['name'] in ['GCC','GCCcore']:
             extras = EB_GCC.make_module_extra(self, *args, **kwargs)
         elif self.cfg['name'] in ['icc']:
             extras = EB_icc.make_module_extra(self, *args, **kwargs)
         elif self.cfg['name'] in ['ifort']:
             extras = EB_ifort.make_module_extra(self, *args, **kwargs)
         else:
             raise EasyBuildError("I don't know how to generate extra module text for %s", self.cfg['name'])
     else:
         extras = super(SystemCompiler, self).make_module_extra(*args, **kwargs)
     return extras
 def extra_options():
     """Add custom easyconfig parameters for SystemCompiler easyblock."""
     # Gather extra_vars from inherited classes, order matters here to make this work without problems in __init__
     extra_vars = EB_GCC.extra_options()
     extra_vars.update(EB_icc.extra_options())
     extra_vars.update(EB_ifort.extra_options())
     extra_vars.update(Bundle.extra_options())
     # Add an option to add all module path extensions to the resultant easyconfig
     # This is useful if you are importing a compiler from a non-default path
     extra_vars.update({
         'generate_standalone_module': [
             False,
             "Add known path/library extensions and environment variables for the compiler to the final module",
             CUSTOM
         ],
     })
     return extra_vars
 def extra_options():
     """Add custom easyconfig parameters for SystemCompiler easyblock."""
     # Gather extra_vars from inherited classes, order matters here to make this work without problems in __init__
     extra_vars = EB_GCC.extra_options()
     extra_vars.update(EB_icc.extra_options())
     extra_vars.update(EB_ifort.extra_options())
     extra_vars.update(Bundle.extra_options())
     # Add an option to add all module path extensions to the resultant easyconfig
     # This is useful if you are importing a compiler from a non-default path
     extra_vars.update({
         'generate_standalone_module': [
             False,
             "Add known path/library extensions and environment variables for the compiler to the final module",
             CUSTOM
         ],
     })
     return extra_vars
 def make_module_req_guess(self):
     """
     A dictionary of possible directories to look for.  Return known dict for the system compiler, or empty dict if
     generate_standalone_module parameter is False
     """
     guesses = {}
     if self.cfg['generate_standalone_module']:
         if self.compiler_prefix in ['/usr', '/usr/local']:
             # Force off adding paths to module since unloading such a module would be a potential shell killer
             print_warning("Ignoring option 'generate_standalone_module' since installation prefix is %s",
                           self.compiler_prefix)
         else:
             if self.cfg['name'] in ['GCC','GCCcore']:
                 guesses = EB_GCC.make_module_req_guess(self)
             elif self.cfg['name'] in ['icc']:
                 guesses = EB_icc.make_module_req_guess(self)
             elif self.cfg['name'] in ['ifort']:
                 guesses = EB_ifort.make_module_req_guess(self)
             else:
                 raise EasyBuildError("I don't know how to generate module var guesses for %s", self.cfg['name'])
     return guesses
    def make_module_req_guess(self):
        # Use EB_icc because its make_module_req_guess deliberately omits 'include' for CPATH:
        # including it causes problems, e.g. with complex.h and std::complex
        # cfr. https://software.intel.com/en-us/forums/intel-c-compiler/topic/338378
        # whereas EB_ifort adds 'include' but that's only needed if icc and ifort are separate
        guesses = EB_icc.make_module_req_guess(self)

        # remove entries from LIBRARY_PATH that icc and co already know about at compile time
        # only do this for iccifort merged installations so that icc can still find ifort
        # libraries and vice versa for split installations
        if self.comp_libs_subdir is not None:
            compiler_library_paths = [
                os.path.join(self.comp_libs_subdir, p)
                for p in ('lib', 'compiler/lib/intel64', 'lib/ia32',
                          'lib/intel64')
            ]
            guesses['LIBRARY_PATH'] = [
                p for p in guesses['LIBRARY_PATH']
                if p not in compiler_library_paths
            ]
        return guesses
    def prepare_step(self, *args, **kwargs):
        """Do compiler appropriate prepare step, determine system compiler version and prefix."""
        if self.cfg['generate_standalone_module']:
            if self.cfg['name'] in ['GCC', 'GCCcore']:
                EB_GCC.prepare_step(self, *args, **kwargs)
            elif self.cfg['name'] in ['icc']:
                EB_icc.prepare_step(self, *args, **kwargs)
            elif self.cfg['name'] in ['ifort']:
                EB_ifort.prepare_step(self, *args, **kwargs)
            else:
                raise EasyBuildError(
                    "I don't know how to do the prepare_step for %s",
                    self.cfg['name'])
        else:
            Bundle.prepare_step(self, *args, **kwargs)

        # Determine compiler path (real path, with resolved symlinks)
        compiler_name = self.cfg['name'].lower()
        if compiler_name == 'gcccore':
            compiler_name = 'gcc'
        path_to_compiler = which(compiler_name)
        if path_to_compiler:
            path_to_compiler = resolve_path(path_to_compiler)
            self.log.info(
                "Found path to compiler '%s' (with symlinks resolved): %s",
                compiler_name, path_to_compiler)
        else:
            raise EasyBuildError("%s not found in $PATH", compiler_name)

        # Determine compiler version
        self.compiler_version = extract_compiler_version(compiler_name)

        # Determine installation prefix
        if compiler_name == 'gcc':
            # strip off 'bin/gcc'
            self.compiler_prefix = os.path.dirname(
                os.path.dirname(path_to_compiler))

        elif compiler_name in ['icc', 'ifort']:
            intelvars_fn = path_to_compiler + 'vars.sh'
            if os.path.isfile(intelvars_fn):
                self.log.debug(
                    "Trying to determine compiler install prefix from %s",
                    intelvars_fn)
                intelvars_txt = read_file(intelvars_fn)
                prod_dir_regex = re.compile(r'^PROD_DIR=(.*)$', re.M)
                res = prod_dir_regex.search(intelvars_txt)
                if res:
                    self.compiler_prefix = res.group(1)
                else:
                    raise EasyBuildError(
                        "Failed to determine %s installation prefix from %s",
                        compiler_name, intelvars_fn)
            else:
                # strip off 'bin/intel*/icc'
                self.compiler_prefix = os.path.dirname(
                    os.path.dirname(os.path.dirname(path_to_compiler)))

            # For versions 2016+ of Intel compilers they changed the installation path so must shave off 2 more
            # directories from result of the above
            if LooseVersion(self.compiler_version) >= LooseVersion('2016'):
                self.compiler_prefix = os.path.dirname(
                    os.path.dirname(self.compiler_prefix))

        else:
            raise EasyBuildError("Unknown system compiler %s" %
                                 self.cfg['name'])

        if not os.path.exists(self.compiler_prefix):
            raise EasyBuildError(
                "Path derived for system compiler (%s) does not exist: %s!",
                compiler_name, self.compiler_prefix)
        self.log.debug(
            "Derived version/install prefix for system compiler %s: %s, %s",
            compiler_name, self.compiler_version, self.compiler_prefix)

        # If EasyConfig specified "real" version (not 'system' which means 'derive automatically'), check it
        if self.cfg['version'] == 'system':
            self.log.info(
                "Found specified version '%s', going with derived compiler version '%s'",
                self.cfg['version'], self.compiler_version)
        elif self.cfg['version'] != self.compiler_version:
            raise EasyBuildError(
                "Specified version (%s) does not match version reported by compiler (%s)"
                % (self.cfg['version'], self.compiler_version))
 def sanity_check_step(self):
     """Custom sanity check paths for iccifort."""
     EB_icc.sanity_check_step(self)
     EB_ifort.sanity_check_step(self)
    def prepare_step(self, *args, **kwargs):
        """Do compiler appropriate prepare step, determine system compiler version and prefix."""
        if self.cfg['generate_standalone_module']:
            if self.cfg['name'] in ['GCC', 'GCCcore']:
                EB_GCC.prepare_step(self, *args, **kwargs)
            elif self.cfg['name'] in ['icc']:
                EB_icc.prepare_step(self, *args, **kwargs)
            elif self.cfg['name'] in ['ifort']:
                EB_ifort.prepare_step(self, *args, **kwargs)
            else:
                raise EasyBuildError("I don't know how to do the prepare_step for %s", self.cfg['name'])
        else:
            Bundle.prepare_step(self, *args, **kwargs)
            
        # Determine compiler path (real path, with resolved symlinks)
        compiler_name = self.cfg['name'].lower()
        if compiler_name == 'gcccore':
            compiler_name = 'gcc'
        path_to_compiler = which(compiler_name)
        if path_to_compiler:
            path_to_compiler = resolve_path(path_to_compiler)
            self.log.info("Found path to compiler '%s' (with symlinks resolved): %s", compiler_name, path_to_compiler)
        else:
            raise EasyBuildError("%s not found in $PATH", compiler_name)

        # Determine compiler version
        self.compiler_version = extract_compiler_version(compiler_name)

        # Determine installation prefix
        if compiler_name == 'gcc':
            # strip off 'bin/gcc'
            self.compiler_prefix = os.path.dirname(os.path.dirname(path_to_compiler))

        elif compiler_name in ['icc', 'ifort']:
            intelvars_fn = path_to_compiler + 'vars.sh'
            if os.path.isfile(intelvars_fn):
                self.log.debug("Trying to determine compiler install prefix from %s", intelvars_fn)
                intelvars_txt = read_file(intelvars_fn)
                prod_dir_regex = re.compile(r'^PROD_DIR=(.*)$', re.M)
                res = prod_dir_regex.search(intelvars_txt)
                if res:
                    self.compiler_prefix = res.group(1)
                else:
                    raise EasyBuildError("Failed to determine %s installation prefix from %s",
                                          compiler_name, intelvars_fn)
            else:
                # strip off 'bin/intel*/icc'
                self.compiler_prefix = os.path.dirname(os.path.dirname(os.path.dirname(path_to_compiler)))

            # For versions 2016+ of Intel compilers they changed the installation path so must shave off 2 more
            # directories from result of the above
            if LooseVersion(self.compiler_version) >= LooseVersion('2016'):
                self.compiler_prefix = os.path.dirname(os.path.dirname(self.compiler_prefix))

        else:
            raise EasyBuildError("Unknown system compiler %s" % self.cfg['name'])

        if not os.path.exists(self.compiler_prefix):
            raise EasyBuildError("Path derived for system compiler (%s) does not exist: %s!",
                                 compiler_name, self.compiler_prefix)
        self.log.debug("Derived version/install prefix for system compiler %s: %s, %s",
                       compiler_name, self.compiler_version, self.compiler_prefix)

        # If EasyConfig specified "real" version (not 'system' which means 'derive automatically'), check it
        if self.cfg['version'] == 'system':
            self.log.info("Found specified version '%s', going with derived compiler version '%s'",
                          self.cfg['version'], self.compiler_version)
        elif self.cfg['version'] != self.compiler_version:
            raise EasyBuildError("Specified version (%s) does not match version reported by compiler (%s)" %
                                 (self.cfg['version'], self.compiler_version))