def find_compiler(self, cmp_cls, *path): """Try to find the given type of compiler in the user's environment. For each set of compilers found, this returns compiler objects with the cc, cxx, f77, fc paths and the version filled in. This will search for compilers with the names in cc_names, cxx_names, etc. and it will group them if they have common prefixes, suffixes, and versions. e.g., gcc-mp-4.7 would be grouped with g++-mp-4.7 and gfortran-mp-4.7. """ dicts = parmap( lambda t: cmp_cls._find_matches_in_path(*t), [(cmp_cls.cc_names, cmp_cls.cc_version) + tuple(path), (cmp_cls.cxx_names, cmp_cls.cxx_version) + tuple(path), (cmp_cls.f77_names, cmp_cls.f77_version) + tuple(path), (cmp_cls.fc_names, cmp_cls.fc_version) + tuple(path)]) all_keys = set() for d in dicts: all_keys.update(d) compilers = {} for k in all_keys: ver, pre, suf = k # Skip compilers with unknown version. if ver == 'unknown': continue paths = tuple(pn[k] if k in pn else None for pn in dicts) spec = spack.spec.CompilerSpec(cmp_cls.name, ver) if ver in compilers: prev = compilers[ver] # prefer the one with more compilers. prev_paths = [prev.cc, prev.cxx, prev.f77, prev.fc] newcount = len([p for p in paths if p is not None]) prevcount = len([p for p in prev_paths if p is not None]) # Don't add if it's not an improvement over prev compiler. if newcount <= prevcount: continue compilers[ver] = cmp_cls(spec, self, py_platform.machine(), paths) return list(compilers.values())