def use_configuration(*scopes_or_paths): """Use the configuration scopes passed as arguments within the context manager. Args: *scopes_or_paths: scope objects or paths to be used Returns: Configuration object associated with the scopes passed as arguments """ global config # Normalize input and construct a Configuration object configuration = _config_from(scopes_or_paths) config.clear_caches(), configuration.clear_caches() # Save and clear the current compiler cache saved_compiler_cache = spack.compilers._cache_config_file spack.compilers._cache_config_file = [] saved_config, config = config, configuration yield configuration # Restore previous config files spack.compilers._cache_config_file = saved_compiler_cache config = saved_config
def replace_config(configuration): """Replace the current global configuration with the instance passed as argument. Args: configuration (Configuration): the new configuration to be used. Returns: The old configuration that has been removed """ global config config.clear_caches(), configuration.clear_caches() old_config, config = config, configuration return old_config