summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2018-08-23 10:21:18 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2018-08-27 14:49:50 -0700
commit6f5a68a58dec07c1e7699513d373b2e8a6fcd77f (patch)
tree5e38d54499fedd5d380cf896c0db8f7b9451c7c3 /lib
parent8ecf5ae2eebf85e580e0a23ccd2bebed094c507f (diff)
downloadspack-6f5a68a58dec07c1e7699513d373b2e8a6fcd77f.tar.gz
spack-6f5a68a58dec07c1e7699513d373b2e8a6fcd77f.tar.bz2
spack-6f5a68a58dec07c1e7699513d373b2e8a6fcd77f.tar.xz
spack-6f5a68a58dec07c1e7699513d373b2e8a6fcd77f.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/__init__.py20
-rw-r--r--lib/spack/spack/cmd/compiler.py8
-rw-r--r--lib/spack/spack/cmd/config.py3
-rw-r--r--lib/spack/spack/cmd/mirror.py6
-rw-r--r--lib/spack/spack/cmd/repo.py6
-rw-r--r--lib/spack/spack/config.py20
-rw-r--r--lib/spack/spack/modules/lmod.py10
7 files changed, 39 insertions, 34 deletions
diff --git a/lib/spack/spack/cmd/__init__.py b/lib/spack/spack/cmd/__init__.py
index 1a58560f66..ede2296881 100644
--- a/lib/spack/spack/cmd/__init__.py
+++ b/lib/spack/spack/cmd/__init__.py
@@ -40,26 +40,6 @@ import spack.store
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
diff --git a/lib/spack/spack/cmd/compiler.py b/lib/spack/spack/cmd/compiler.py
index 186e6adf7f..687c62e86d 100644
--- a/lib/spack/spack/cmd/compiler.py
+++ b/lib/spack/spack/cmd/compiler.py
@@ -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")
diff --git a/lib/spack/spack/cmd/config.py b/lib/spack/spack/cmd/config.py
index 10ab4c667b..78d45e22f1 100644
--- a/lib/spack/spack/cmd/config.py
+++ b/lib/spack/spack/cmd/config.py
@@ -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:
diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py
index 0ab2dc4424..f42e990329 100644
--- a/lib/spack/spack/cmd/mirror.py
+++ b/lib/spack/spack/cmd/mirror.py
@@ -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")
diff --git a/lib/spack/spack/cmd/repo.py b/lib/spack/spack/cmd/repo.py
index 802dbd3950..6a25e03e91 100644
--- a/lib/spack/spack/cmd/repo.py
+++ b/lib/spack/spack/cmd/repo.py
@@ -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")
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index c1216450b1..f1f9e8da95 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -752,6 +752,26 @@ def _merge_yaml(dest, 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):
"""Superclass for all Spack config related errors."""
diff --git a/lib/spack/spack/modules/lmod.py b/lib/spack/spack/modules/lmod.py
index a057f2bf3a..858b01a395 100644
--- a/lib/spack/spack/modules/lmod.py
+++ b/lib/spack/spack/modules/lmod.py
@@ -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