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
|
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
|
# cmd has a submodule called "list" so preserve the python list module
|
||||||
python_list = list
|
python_list = list
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ def setup_parser(subparser):
|
|||||||
find_parser.add_argument('add_paths', nargs=argparse.REMAINDER)
|
find_parser.add_argument('add_paths', nargs=argparse.REMAINDER)
|
||||||
find_parser.add_argument(
|
find_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify")
|
help="configuration scope to modify")
|
||||||
|
|
||||||
# Remove
|
# Remove
|
||||||
@ -68,14 +68,14 @@ def setup_parser(subparser):
|
|||||||
remove_parser.add_argument('compiler_spec')
|
remove_parser.add_argument('compiler_spec')
|
||||||
remove_parser.add_argument(
|
remove_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify")
|
help="configuration scope to modify")
|
||||||
|
|
||||||
# List
|
# List
|
||||||
list_parser = sp.add_parser('list', help='list available compilers')
|
list_parser = sp.add_parser('list', help='list available compilers')
|
||||||
list_parser.add_argument(
|
list_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_list_scope(),
|
default=spack.config.default_list_scope(),
|
||||||
help="configuration scope to read from")
|
help="configuration scope to read from")
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
@ -83,7 +83,7 @@ def setup_parser(subparser):
|
|||||||
info_parser.add_argument('compiler_spec')
|
info_parser.add_argument('compiler_spec')
|
||||||
info_parser.add_argument(
|
info_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_list_scope(),
|
default=spack.config.default_list_scope(),
|
||||||
help="configuration scope to read from")
|
help="configuration scope to read from")
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
import spack.config
|
import spack.config
|
||||||
|
|
||||||
from spack.util.editor import editor
|
from spack.util.editor import editor
|
||||||
|
|
||||||
description = "get and set configuration options"
|
description = "get and set configuration options"
|
||||||
@ -75,7 +76,7 @@ def config_blame(args):
|
|||||||
def config_edit(args):
|
def config_edit(args):
|
||||||
if not args.scope:
|
if not args.scope:
|
||||||
if args.section == 'compilers':
|
if args.section == 'compilers':
|
||||||
args.scope = spack.cmd.default_modify_scope()
|
args.scope = spack.config.default_modify_scope()
|
||||||
else:
|
else:
|
||||||
args.scope = 'user'
|
args.scope = 'user'
|
||||||
if not args.section:
|
if not args.section:
|
||||||
|
@ -78,7 +78,7 @@ def setup_parser(subparser):
|
|||||||
'url', help="url of mirror directory from 'spack mirror create'")
|
'url', help="url of mirror directory from 'spack mirror create'")
|
||||||
add_parser.add_argument(
|
add_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify")
|
help="configuration scope to modify")
|
||||||
|
|
||||||
# Remove
|
# Remove
|
||||||
@ -87,14 +87,14 @@ def setup_parser(subparser):
|
|||||||
remove_parser.add_argument('name')
|
remove_parser.add_argument('name')
|
||||||
remove_parser.add_argument(
|
remove_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify")
|
help="configuration scope to modify")
|
||||||
|
|
||||||
# List
|
# List
|
||||||
list_parser = sp.add_parser('list', help=mirror_list.__doc__)
|
list_parser = sp.add_parser('list', help=mirror_list.__doc__)
|
||||||
list_parser.add_argument(
|
list_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_list_scope(),
|
default=spack.config.default_list_scope(),
|
||||||
help="configuration scope to read from")
|
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 = sp.add_parser('list', help=repo_list.__doc__)
|
||||||
list_parser.add_argument(
|
list_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_list_scope(),
|
default=spack.config.default_list_scope(),
|
||||||
help="configuration scope to read from")
|
help="configuration scope to read from")
|
||||||
|
|
||||||
# Add
|
# Add
|
||||||
@ -63,7 +63,7 @@ def setup_parser(subparser):
|
|||||||
'path', help="path to a Spack package repository directory")
|
'path', help="path to a Spack package repository directory")
|
||||||
add_parser.add_argument(
|
add_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify")
|
help="configuration scope to modify")
|
||||||
|
|
||||||
# Remove
|
# Remove
|
||||||
@ -74,7 +74,7 @@ def setup_parser(subparser):
|
|||||||
help="path or namespace of a Spack package repository")
|
help="path or namespace of a Spack package repository")
|
||||||
remove_parser.add_argument(
|
remove_parser.add_argument(
|
||||||
'--scope', choices=scopes, metavar=scopes_metavar,
|
'--scope', choices=scopes, metavar=scopes_metavar,
|
||||||
default=spack.cmd.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify")
|
help="configuration scope to modify")
|
||||||
|
|
||||||
|
|
||||||
|
@ -752,6 +752,26 @@ def they_are(t):
|
|||||||
return copy.copy(source)
|
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):
|
class ConfigError(SpackError):
|
||||||
"""Superclass for all Spack config related errors."""
|
"""Superclass for all Spack config related errors."""
|
||||||
|
|
||||||
|
@ -92,11 +92,15 @@ def guess_core_compilers(store=False):
|
|||||||
|
|
||||||
if store and core_compilers:
|
if store and core_compilers:
|
||||||
# If we asked to store core compilers, update the entry
|
# 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)
|
# 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
|
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
|
return core_compilers or None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user