Moved functions returning default scopes to spack.config
The functions returning the default scope to be modified or listed have been moved from spack.cmd to spack.config. Lmod now writes the guessed core compiler in the default modify scope instead of the 'site' scope.
This commit is contained in:
parent
8ecf5ae2ee
commit
6f5a68a58d
@ -40,26 +40,6 @@
|
||||
from spack.error import SpackError
|
||||
|
||||
|
||||
#
|
||||
# Settings for commands that modify configuration
|
||||
#
|
||||
def default_modify_scope():
|
||||
"""Return the config scope that commands should modify by default.
|
||||
|
||||
Commands that modify configuration by default modify the *highest*
|
||||
priority scope.
|
||||
"""
|
||||
return spack.config.config.highest_precedence_scope().name
|
||||
|
||||
|
||||
def default_list_scope():
|
||||
"""Return the config scope that is listed by default.
|
||||
|
||||
Commands that list configuration list *all* scopes (merged) by default.
|
||||
"""
|
||||
return None
|
||||
|
||||
|
||||
# cmd has a submodule called "list" so preserve the python list module
|
||||
python_list = list
|
||||
|
||||
|
@ -56,7 +56,7 @@ def setup_parser(subparser):
|
||||
find_parser.add_argument('add_paths', nargs=argparse.REMAINDER)
|
||||
find_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_modify_scope(),
|
||||
default=spack.config.default_modify_scope(),
|
||||
help="configuration scope to modify")
|
||||
|
||||
# Remove
|
||||
@ -68,14 +68,14 @@ def setup_parser(subparser):
|
||||
remove_parser.add_argument('compiler_spec')
|
||||
remove_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_modify_scope(),
|
||||
default=spack.config.default_modify_scope(),
|
||||
help="configuration scope to modify")
|
||||
|
||||
# List
|
||||
list_parser = sp.add_parser('list', help='list available compilers')
|
||||
list_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_list_scope(),
|
||||
default=spack.config.default_list_scope(),
|
||||
help="configuration scope to read from")
|
||||
|
||||
# Info
|
||||
@ -83,7 +83,7 @@ def setup_parser(subparser):
|
||||
info_parser.add_argument('compiler_spec')
|
||||
info_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_list_scope(),
|
||||
default=spack.config.default_list_scope(),
|
||||
help="configuration scope to read from")
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
import spack.config
|
||||
|
||||
from spack.util.editor import editor
|
||||
|
||||
description = "get and set configuration options"
|
||||
@ -75,7 +76,7 @@ def config_blame(args):
|
||||
def config_edit(args):
|
||||
if not args.scope:
|
||||
if args.section == 'compilers':
|
||||
args.scope = spack.cmd.default_modify_scope()
|
||||
args.scope = spack.config.default_modify_scope()
|
||||
else:
|
||||
args.scope = 'user'
|
||||
if not args.section:
|
||||
|
@ -78,7 +78,7 @@ def setup_parser(subparser):
|
||||
'url', help="url of mirror directory from 'spack mirror create'")
|
||||
add_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_modify_scope(),
|
||||
default=spack.config.default_modify_scope(),
|
||||
help="configuration scope to modify")
|
||||
|
||||
# Remove
|
||||
@ -87,14 +87,14 @@ def setup_parser(subparser):
|
||||
remove_parser.add_argument('name')
|
||||
remove_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_modify_scope(),
|
||||
default=spack.config.default_modify_scope(),
|
||||
help="configuration scope to modify")
|
||||
|
||||
# List
|
||||
list_parser = sp.add_parser('list', help=mirror_list.__doc__)
|
||||
list_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_list_scope(),
|
||||
default=spack.config.default_list_scope(),
|
||||
help="configuration scope to read from")
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ def setup_parser(subparser):
|
||||
list_parser = sp.add_parser('list', help=repo_list.__doc__)
|
||||
list_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_list_scope(),
|
||||
default=spack.config.default_list_scope(),
|
||||
help="configuration scope to read from")
|
||||
|
||||
# Add
|
||||
@ -63,7 +63,7 @@ def setup_parser(subparser):
|
||||
'path', help="path to a Spack package repository directory")
|
||||
add_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_modify_scope(),
|
||||
default=spack.config.default_modify_scope(),
|
||||
help="configuration scope to modify")
|
||||
|
||||
# Remove
|
||||
@ -74,7 +74,7 @@ def setup_parser(subparser):
|
||||
help="path or namespace of a Spack package repository")
|
||||
remove_parser.add_argument(
|
||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||
default=spack.cmd.default_modify_scope(),
|
||||
default=spack.config.default_modify_scope(),
|
||||
help="configuration scope to modify")
|
||||
|
||||
|
||||
|
@ -752,6 +752,26 @@ def they_are(t):
|
||||
return copy.copy(source)
|
||||
|
||||
|
||||
#
|
||||
# Settings for commands that modify configuration
|
||||
#
|
||||
def default_modify_scope():
|
||||
"""Return the config scope that commands should modify by default.
|
||||
|
||||
Commands that modify configuration by default modify the *highest*
|
||||
priority scope.
|
||||
"""
|
||||
return spack.config.config.highest_precedence_scope().name
|
||||
|
||||
|
||||
def default_list_scope():
|
||||
"""Return the config scope that is listed by default.
|
||||
|
||||
Commands that list configuration list *all* scopes (merged) by default.
|
||||
"""
|
||||
return None
|
||||
|
||||
|
||||
class ConfigError(SpackError):
|
||||
"""Superclass for all Spack config related errors."""
|
||||
|
||||
|
@ -92,11 +92,15 @@ def guess_core_compilers(store=False):
|
||||
|
||||
if store and core_compilers:
|
||||
# If we asked to store core compilers, update the entry
|
||||
# at 'site' scope (i.e. within the directory hierarchy
|
||||
# in the default modify scope (i.e. within the directory hierarchy
|
||||
# of Spack itself)
|
||||
modules_cfg = spack.config.get('modules', scope='site')
|
||||
modules_cfg = spack.config.get(
|
||||
'modules', scope=spack.config.default_modify_scope()
|
||||
)
|
||||
modules_cfg.setdefault('lmod', {})['core_compilers'] = core_compilers
|
||||
spack.config.set('modules', modules_cfg, scope='site')
|
||||
spack.config.set(
|
||||
'modules', modules_cfg, scope=spack.config.default_modify_scope()
|
||||
)
|
||||
|
||||
return core_compilers or None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user