def _get_mirrors(): """Get mirrors from spack configuration.""" config = spack.config.get_config() mirrors = [] sec_names = config.get_section_names('mirror') for name in sec_names: mirrors.append(config.get_value('mirror', name, 'url')) return mirrors
def mirror_list(args): """Print out available mirrors to the console.""" config = spack.config.get_config() sec_names = config.get_section_names('mirror') if not sec_names: tty.msg("No mirrors configured.") return max_len = max(len(s) for s in sec_names) fmt = "%%-%ds%%s" % (max_len + 4) for name in sec_names: val = config.get_value('mirror', name, 'url') print fmt % (name, val)
def _get_config(): """Get a Spack config, but make sure it has compiler configuration first.""" # If any configuration file has compilers, just stick with the # ones already configured. config = spack.config.get_config() existing = [spack.spec.CompilerSpec(s) for s in config.get_section_names('compiler')] if existing: return config compilers = find_compilers(*get_path('PATH')) new_compilers = [ c for c in compilers if c.spec not in existing] add_compilers_to_config('user', *new_compilers) # After writing compilers to the user config, return a full config # from all files. return spack.config.get_config(refresh=True)
def _get_config(): """Get a Spack config, but make sure it has compiler configuration first.""" # If any configuration file has compilers, just stick with the # ones already configured. config = spack.config.get_config() existing = [ spack.spec.CompilerSpec(s) for s in config.get_section_names('compiler') ] if existing: return config compilers = find_compilers(*get_path('PATH')) new_compilers = [c for c in compilers if c.spec not in existing] add_compilers_to_config('user', *new_compilers) # After writing compilers to the user config, return a full config # from all files. return spack.config.get_config(refresh=True)