spack.config: use all caps for globals (#39424)
This commit is contained in:
parent
fc1d9ba550
commit
0976ad3184
29 changed files with 147 additions and 160 deletions
|
@ -124,9 +124,9 @@ def _read_and_sanitize_configuration() -> Dict[str, Any]:
|
||||||
def _bootstrap_config_scopes() -> Sequence["spack.config.ConfigScope"]:
|
def _bootstrap_config_scopes() -> Sequence["spack.config.ConfigScope"]:
|
||||||
tty.debug("[BOOTSTRAP CONFIG SCOPE] name=_builtin")
|
tty.debug("[BOOTSTRAP CONFIG SCOPE] name=_builtin")
|
||||||
config_scopes: MutableSequence["spack.config.ConfigScope"] = [
|
config_scopes: MutableSequence["spack.config.ConfigScope"] = [
|
||||||
spack.config.InternalConfigScope("_builtin", spack.config.config_defaults)
|
spack.config.InternalConfigScope("_builtin", spack.config.CONFIG_DEFAULTS)
|
||||||
]
|
]
|
||||||
configuration_paths = (spack.config.configuration_defaults_path, ("bootstrap", _config_path()))
|
configuration_paths = (spack.config.CONFIGURATION_DEFAULTS_PATH, ("bootstrap", _config_path()))
|
||||||
for name, path in configuration_paths:
|
for name, path in configuration_paths:
|
||||||
platform = spack.platforms.host().name
|
platform = spack.platforms.host().name
|
||||||
platform_scope = spack.config.ConfigScope(
|
platform_scope = spack.config.ConfigScope(
|
||||||
|
|
|
@ -69,11 +69,10 @@
|
||||||
|
|
||||||
def _add_scope_option(parser):
|
def _add_scope_option(parser):
|
||||||
scopes = spack.config.scopes()
|
scopes = spack.config.scopes()
|
||||||
scopes_metavar = spack.config.scopes_metavar
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
help="configuration scope to read/modify",
|
help="configuration scope to read/modify",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -170,7 +169,7 @@ def _reset(args):
|
||||||
if not ok_to_continue:
|
if not ok_to_continue:
|
||||||
raise RuntimeError("Aborting")
|
raise RuntimeError("Aborting")
|
||||||
|
|
||||||
for scope in spack.config.config.file_scopes:
|
for scope in spack.config.CONFIG.file_scopes:
|
||||||
# The default scope should stay untouched
|
# The default scope should stay untouched
|
||||||
if scope.name == "defaults":
|
if scope.name == "defaults":
|
||||||
continue
|
continue
|
||||||
|
@ -187,7 +186,7 @@ def _reset(args):
|
||||||
if os.path.exists(bootstrap_yaml):
|
if os.path.exists(bootstrap_yaml):
|
||||||
shutil.move(bootstrap_yaml, backup_file)
|
shutil.move(bootstrap_yaml, backup_file)
|
||||||
|
|
||||||
spack.config.config.clear_caches()
|
spack.config.CONFIG.clear_caches()
|
||||||
|
|
||||||
|
|
||||||
def _root(args):
|
def _root(args):
|
||||||
|
|
|
@ -149,12 +149,11 @@ def setup_parser(subparser: argparse.ArgumentParser):
|
||||||
|
|
||||||
# used to construct scope arguments below
|
# used to construct scope arguments below
|
||||||
scopes = spack.config.scopes()
|
scopes = spack.config.scopes()
|
||||||
scopes_metavar = spack.config.scopes_metavar
|
|
||||||
|
|
||||||
check.add_argument(
|
check.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope containing mirrors to check",
|
help="configuration scope containing mirrors to check",
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,7 +24,6 @@ def setup_parser(subparser):
|
||||||
sp = subparser.add_subparsers(metavar="SUBCOMMAND", dest="compiler_command")
|
sp = subparser.add_subparsers(metavar="SUBCOMMAND", dest="compiler_command")
|
||||||
|
|
||||||
scopes = spack.config.scopes()
|
scopes = spack.config.scopes()
|
||||||
scopes_metavar = spack.config.scopes_metavar
|
|
||||||
|
|
||||||
# Find
|
# Find
|
||||||
find_parser = sp.add_parser(
|
find_parser = sp.add_parser(
|
||||||
|
@ -36,7 +35,7 @@ def setup_parser(subparser):
|
||||||
find_parser.add_argument(
|
find_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_modify_scope("compilers"),
|
default=spack.config.default_modify_scope("compilers"),
|
||||||
help="configuration scope to modify",
|
help="configuration scope to modify",
|
||||||
)
|
)
|
||||||
|
@ -50,7 +49,7 @@ def setup_parser(subparser):
|
||||||
remove_parser.add_argument(
|
remove_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=None,
|
default=None,
|
||||||
help="configuration scope to modify",
|
help="configuration scope to modify",
|
||||||
)
|
)
|
||||||
|
@ -60,7 +59,7 @@ def setup_parser(subparser):
|
||||||
list_parser.add_argument(
|
list_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_list_scope(),
|
default=spack.config.default_list_scope(),
|
||||||
help="configuration scope to read from",
|
help="configuration scope to read from",
|
||||||
)
|
)
|
||||||
|
@ -71,7 +70,7 @@ def setup_parser(subparser):
|
||||||
info_parser.add_argument(
|
info_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_list_scope(),
|
default=spack.config.default_list_scope(),
|
||||||
help="configuration scope to read from",
|
help="configuration scope to read from",
|
||||||
)
|
)
|
||||||
|
@ -93,7 +92,7 @@ def compiler_find(args):
|
||||||
n = len(new_compilers)
|
n = len(new_compilers)
|
||||||
s = "s" if n > 1 else ""
|
s = "s" if n > 1 else ""
|
||||||
|
|
||||||
config = spack.config.config
|
config = spack.config.CONFIG
|
||||||
filename = config.get_config_filename(args.scope, "compilers")
|
filename = config.get_config_filename(args.scope, "compilers")
|
||||||
tty.msg("Added %d new compiler%s to %s" % (n, s, filename))
|
tty.msg("Added %d new compiler%s to %s" % (n, s, filename))
|
||||||
colify(reversed(sorted(c.spec.display_str for c in new_compilers)), indent=4)
|
colify(reversed(sorted(c.spec.display_str for c in new_compilers)), indent=4)
|
||||||
|
|
|
@ -13,12 +13,11 @@
|
||||||
|
|
||||||
def setup_parser(subparser):
|
def setup_parser(subparser):
|
||||||
scopes = spack.config.scopes()
|
scopes = spack.config.scopes()
|
||||||
scopes_metavar = spack.config.scopes_metavar
|
|
||||||
|
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
help="configuration scope to read/modify",
|
help="configuration scope to read/modify",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,12 @@
|
||||||
|
|
||||||
def setup_parser(subparser):
|
def setup_parser(subparser):
|
||||||
scopes = spack.config.scopes()
|
scopes = spack.config.scopes()
|
||||||
scopes_metavar = spack.config.scopes_metavar
|
|
||||||
|
|
||||||
# User can only choose one
|
# User can only choose one
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
help="configuration scope to read/modify",
|
help="configuration scope to read/modify",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ def setup_parser(subparser):
|
||||||
help="configuration section to print\n\noptions: %(choices)s",
|
help="configuration section to print\n\noptions: %(choices)s",
|
||||||
nargs="?",
|
nargs="?",
|
||||||
metavar="section",
|
metavar="section",
|
||||||
choices=spack.config.section_schemas,
|
choices=spack.config.SECTION_SCHEMAS,
|
||||||
)
|
)
|
||||||
|
|
||||||
blame_parser = sp.add_parser(
|
blame_parser = sp.add_parser(
|
||||||
|
@ -55,7 +54,7 @@ def setup_parser(subparser):
|
||||||
"section",
|
"section",
|
||||||
help="configuration section to print\n\noptions: %(choices)s",
|
help="configuration section to print\n\noptions: %(choices)s",
|
||||||
metavar="section",
|
metavar="section",
|
||||||
choices=spack.config.section_schemas,
|
choices=spack.config.SECTION_SCHEMAS,
|
||||||
)
|
)
|
||||||
|
|
||||||
edit_parser = sp.add_parser("edit", help="edit configuration file")
|
edit_parser = sp.add_parser("edit", help="edit configuration file")
|
||||||
|
@ -64,7 +63,7 @@ def setup_parser(subparser):
|
||||||
help="configuration section to edit\n\noptions: %(choices)s",
|
help="configuration section to edit\n\noptions: %(choices)s",
|
||||||
metavar="section",
|
metavar="section",
|
||||||
nargs="?",
|
nargs="?",
|
||||||
choices=spack.config.section_schemas,
|
choices=spack.config.SECTION_SCHEMAS,
|
||||||
)
|
)
|
||||||
edit_parser.add_argument(
|
edit_parser.add_argument(
|
||||||
"--print-file", action="store_true", help="print the file name that would be edited"
|
"--print-file", action="store_true", help="print the file name that would be edited"
|
||||||
|
@ -146,10 +145,10 @@ def config_get(args):
|
||||||
scope, section = _get_scope_and_section(args)
|
scope, section = _get_scope_and_section(args)
|
||||||
|
|
||||||
if section is not None:
|
if section is not None:
|
||||||
spack.config.config.print_section(section)
|
spack.config.CONFIG.print_section(section)
|
||||||
|
|
||||||
elif scope and scope.startswith("env:"):
|
elif scope and scope.startswith("env:"):
|
||||||
config_file = spack.config.config.get_config_filename(scope, section)
|
config_file = spack.config.CONFIG.get_config_filename(scope, section)
|
||||||
if os.path.exists(config_file):
|
if os.path.exists(config_file):
|
||||||
with open(config_file) as f:
|
with open(config_file) as f:
|
||||||
print(f.read())
|
print(f.read())
|
||||||
|
@ -162,7 +161,7 @@ def config_get(args):
|
||||||
|
|
||||||
def config_blame(args):
|
def config_blame(args):
|
||||||
"""Print out line-by-line blame of merged YAML."""
|
"""Print out line-by-line blame of merged YAML."""
|
||||||
spack.config.config.print_section(args.section, blame=True)
|
spack.config.CONFIG.print_section(args.section, blame=True)
|
||||||
|
|
||||||
|
|
||||||
def config_edit(args):
|
def config_edit(args):
|
||||||
|
@ -181,7 +180,7 @@ def config_edit(args):
|
||||||
scope, section = _get_scope_and_section(args)
|
scope, section = _get_scope_and_section(args)
|
||||||
if not scope and not section:
|
if not scope and not section:
|
||||||
tty.die("`spack config edit` requires a section argument or an active environment.")
|
tty.die("`spack config edit` requires a section argument or an active environment.")
|
||||||
config_file = spack.config.config.get_config_filename(scope, section)
|
config_file = spack.config.CONFIG.get_config_filename(scope, section)
|
||||||
|
|
||||||
if args.print_file:
|
if args.print_file:
|
||||||
print(config_file)
|
print(config_file)
|
||||||
|
@ -194,7 +193,7 @@ def config_list(args):
|
||||||
|
|
||||||
Used primarily for shell tab completion scripts.
|
Used primarily for shell tab completion scripts.
|
||||||
"""
|
"""
|
||||||
print(" ".join(list(spack.config.section_schemas)))
|
print(" ".join(list(spack.config.SECTION_SCHEMAS)))
|
||||||
|
|
||||||
|
|
||||||
def config_add(args):
|
def config_add(args):
|
||||||
|
@ -251,19 +250,19 @@ def _can_update_config_file(scope: spack.config.ConfigScope, cfg_file):
|
||||||
|
|
||||||
def config_update(args):
|
def config_update(args):
|
||||||
# Read the configuration files
|
# Read the configuration files
|
||||||
spack.config.config.get_config(args.section, scope=args.scope)
|
spack.config.CONFIG.get_config(args.section, scope=args.scope)
|
||||||
updates: List[spack.config.ConfigScope] = list(
|
updates: List[spack.config.ConfigScope] = list(
|
||||||
filter(
|
filter(
|
||||||
lambda s: not isinstance(
|
lambda s: not isinstance(
|
||||||
s, (spack.config.InternalConfigScope, spack.config.ImmutableConfigScope)
|
s, (spack.config.InternalConfigScope, spack.config.ImmutableConfigScope)
|
||||||
),
|
),
|
||||||
spack.config.config.format_updates[args.section],
|
spack.config.CONFIG.format_updates[args.section],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
cannot_overwrite, skip_system_scope = [], False
|
cannot_overwrite, skip_system_scope = [], False
|
||||||
for scope in updates:
|
for scope in updates:
|
||||||
cfg_file = spack.config.config.get_config_filename(scope.name, args.section)
|
cfg_file = spack.config.CONFIG.get_config_filename(scope.name, args.section)
|
||||||
can_be_updated = _can_update_config_file(scope, cfg_file)
|
can_be_updated = _can_update_config_file(scope, cfg_file)
|
||||||
if not can_be_updated:
|
if not can_be_updated:
|
||||||
if scope.name == "system":
|
if scope.name == "system":
|
||||||
|
@ -302,7 +301,7 @@ def config_update(args):
|
||||||
" the latest schema format:\n\n"
|
" the latest schema format:\n\n"
|
||||||
)
|
)
|
||||||
for scope in updates:
|
for scope in updates:
|
||||||
cfg_file = spack.config.config.get_config_filename(scope.name, args.section)
|
cfg_file = spack.config.CONFIG.get_config_filename(scope.name, args.section)
|
||||||
msg += "\t[scope={0}, file={1}]\n".format(scope.name, cfg_file)
|
msg += "\t[scope={0}, file={1}]\n".format(scope.name, cfg_file)
|
||||||
msg += (
|
msg += (
|
||||||
"\nIf the configuration files are updated, versions of Spack "
|
"\nIf the configuration files are updated, versions of Spack "
|
||||||
|
@ -325,7 +324,7 @@ def config_update(args):
|
||||||
# Make a backup copy and rewrite the file
|
# Make a backup copy and rewrite the file
|
||||||
bkp_file = cfg_file + ".bkp"
|
bkp_file = cfg_file + ".bkp"
|
||||||
shutil.copy(cfg_file, bkp_file)
|
shutil.copy(cfg_file, bkp_file)
|
||||||
spack.config.config.update_config(args.section, data, scope=scope.name, force=True)
|
spack.config.CONFIG.update_config(args.section, data, scope=scope.name, force=True)
|
||||||
tty.msg(f'File "{cfg_file}" update [backup={bkp_file}]')
|
tty.msg(f'File "{cfg_file}" update [backup={bkp_file}]')
|
||||||
|
|
||||||
|
|
||||||
|
@ -337,13 +336,13 @@ def _can_revert_update(scope_dir, cfg_file, bkp_file):
|
||||||
|
|
||||||
|
|
||||||
def config_revert(args):
|
def config_revert(args):
|
||||||
scopes = [args.scope] if args.scope else [x.name for x in spack.config.config.file_scopes]
|
scopes = [args.scope] if args.scope else [x.name for x in spack.config.CONFIG.file_scopes]
|
||||||
|
|
||||||
# Search for backup files in the configuration scopes
|
# Search for backup files in the configuration scopes
|
||||||
Entry = collections.namedtuple("Entry", ["scope", "cfg", "bkp"])
|
Entry = collections.namedtuple("Entry", ["scope", "cfg", "bkp"])
|
||||||
to_be_restored, cannot_overwrite = [], []
|
to_be_restored, cannot_overwrite = [], []
|
||||||
for scope in scopes:
|
for scope in scopes:
|
||||||
cfg_file = spack.config.config.get_config_filename(scope, args.section)
|
cfg_file = spack.config.CONFIG.get_config_filename(scope, args.section)
|
||||||
bkp_file = cfg_file + ".bkp"
|
bkp_file = cfg_file + ".bkp"
|
||||||
|
|
||||||
# If the backup files doesn't exist move to the next scope
|
# If the backup files doesn't exist move to the next scope
|
||||||
|
@ -457,7 +456,7 @@ def config_prefer_upstream(args):
|
||||||
existing = spack.config.get("packages", scope=scope)
|
existing = spack.config.get("packages", scope=scope)
|
||||||
new = spack.config.merge_yaml(existing, pkgs)
|
new = spack.config.merge_yaml(existing, pkgs)
|
||||||
spack.config.set("packages", new, scope)
|
spack.config.set("packages", new, scope)
|
||||||
config_file = spack.config.config.get_config_filename(scope, section)
|
config_file = spack.config.CONFIG.get_config_filename(scope, section)
|
||||||
|
|
||||||
tty.msg("Updated config at {0}".format(config_file))
|
tty.msg("Updated config at {0}".format(config_file))
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
import spack
|
import spack
|
||||||
import spack.cmd
|
import spack.cmd
|
||||||
import spack.cmd.common.arguments
|
import spack.cmd.common.arguments
|
||||||
|
import spack.config
|
||||||
import spack.cray_manifest as cray_manifest
|
import spack.cray_manifest as cray_manifest
|
||||||
import spack.detection
|
import spack.detection
|
||||||
import spack.error
|
import spack.error
|
||||||
|
@ -27,7 +28,6 @@ def setup_parser(subparser):
|
||||||
sp = subparser.add_subparsers(metavar="SUBCOMMAND", dest="external_command")
|
sp = subparser.add_subparsers(metavar="SUBCOMMAND", dest="external_command")
|
||||||
|
|
||||||
scopes = spack.config.scopes()
|
scopes = spack.config.scopes()
|
||||||
scopes_metavar = spack.config.scopes_metavar
|
|
||||||
|
|
||||||
find_parser = sp.add_parser("find", help="add external packages to packages.yaml")
|
find_parser = sp.add_parser("find", help="add external packages to packages.yaml")
|
||||||
find_parser.add_argument(
|
find_parser.add_argument(
|
||||||
|
@ -47,7 +47,7 @@ def setup_parser(subparser):
|
||||||
find_parser.add_argument(
|
find_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_modify_scope("packages"),
|
default=spack.config.default_modify_scope("packages"),
|
||||||
help="configuration scope to modify",
|
help="configuration scope to modify",
|
||||||
)
|
)
|
||||||
|
@ -165,7 +165,7 @@ def external_find(args):
|
||||||
detected_packages, scope=args.scope, buildable=not args.not_buildable
|
detected_packages, scope=args.scope, buildable=not args.not_buildable
|
||||||
)
|
)
|
||||||
if new_entries:
|
if new_entries:
|
||||||
path = spack.config.config.get_config_filename(args.scope, "packages")
|
path = spack.config.CONFIG.get_config_filename(args.scope, "packages")
|
||||||
msg = "The following specs have been detected on this system and added to {0}"
|
msg = "The following specs have been detected on this system and added to {0}"
|
||||||
tty.msg(msg.format(path))
|
tty.msg(msg.format(path))
|
||||||
spack.cmd.display_specs(new_entries)
|
spack.cmd.display_specs(new_entries)
|
||||||
|
|
|
@ -90,7 +90,6 @@ def setup_parser(subparser):
|
||||||
|
|
||||||
# used to construct scope arguments below
|
# used to construct scope arguments below
|
||||||
scopes = spack.config.scopes()
|
scopes = spack.config.scopes()
|
||||||
scopes_metavar = spack.config.scopes_metavar
|
|
||||||
|
|
||||||
# Add
|
# Add
|
||||||
add_parser = sp.add_parser("add", help=mirror_add.__doc__)
|
add_parser = sp.add_parser("add", help=mirror_add.__doc__)
|
||||||
|
@ -99,7 +98,7 @@ def setup_parser(subparser):
|
||||||
add_parser.add_argument(
|
add_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify",
|
help="configuration scope to modify",
|
||||||
)
|
)
|
||||||
|
@ -119,7 +118,7 @@ def setup_parser(subparser):
|
||||||
remove_parser.add_argument(
|
remove_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify",
|
help="configuration scope to modify",
|
||||||
)
|
)
|
||||||
|
@ -138,7 +137,7 @@ def setup_parser(subparser):
|
||||||
set_url_parser.add_argument(
|
set_url_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify",
|
help="configuration scope to modify",
|
||||||
)
|
)
|
||||||
|
@ -167,7 +166,7 @@ def setup_parser(subparser):
|
||||||
set_parser.add_argument(
|
set_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify",
|
help="configuration scope to modify",
|
||||||
)
|
)
|
||||||
|
@ -178,7 +177,7 @@ def setup_parser(subparser):
|
||||||
list_parser.add_argument(
|
list_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_list_scope(),
|
default=spack.config.default_list_scope(),
|
||||||
help="configuration scope to read from",
|
help="configuration scope to read from",
|
||||||
)
|
)
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
def setup_parser(subparser):
|
def setup_parser(subparser):
|
||||||
sp = subparser.add_subparsers(metavar="SUBCOMMAND", dest="repo_command")
|
sp = subparser.add_subparsers(metavar="SUBCOMMAND", dest="repo_command")
|
||||||
scopes = spack.config.scopes()
|
scopes = spack.config.scopes()
|
||||||
scopes_metavar = spack.config.scopes_metavar
|
|
||||||
|
|
||||||
# Create
|
# Create
|
||||||
create_parser = sp.add_parser("create", help=repo_create.__doc__)
|
create_parser = sp.add_parser("create", help=repo_create.__doc__)
|
||||||
|
@ -45,7 +44,7 @@ def setup_parser(subparser):
|
||||||
list_parser.add_argument(
|
list_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_list_scope(),
|
default=spack.config.default_list_scope(),
|
||||||
help="configuration scope to read from",
|
help="configuration scope to read from",
|
||||||
)
|
)
|
||||||
|
@ -56,7 +55,7 @@ def setup_parser(subparser):
|
||||||
add_parser.add_argument(
|
add_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify",
|
help="configuration scope to modify",
|
||||||
)
|
)
|
||||||
|
@ -69,7 +68,7 @@ def setup_parser(subparser):
|
||||||
remove_parser.add_argument(
|
remove_parser.add_argument(
|
||||||
"--scope",
|
"--scope",
|
||||||
choices=scopes,
|
choices=scopes,
|
||||||
metavar=scopes_metavar,
|
metavar=spack.config.SCOPES_METAVAR,
|
||||||
default=spack.config.default_modify_scope(),
|
default=spack.config.default_modify_scope(),
|
||||||
help="configuration scope to modify",
|
help="configuration scope to modify",
|
||||||
)
|
)
|
||||||
|
|
|
@ -135,7 +135,7 @@ def _init_compiler_config(*, scope):
|
||||||
|
|
||||||
def compiler_config_files():
|
def compiler_config_files():
|
||||||
config_files = list()
|
config_files = list()
|
||||||
config = spack.config.config
|
config = spack.config.CONFIG
|
||||||
for scope in config.file_scopes:
|
for scope in config.file_scopes:
|
||||||
name = scope.name
|
name = scope.name
|
||||||
compiler_config = config.get("compilers", scope=name)
|
compiler_config = config.get("compilers", scope=name)
|
||||||
|
@ -169,7 +169,7 @@ def remove_compiler_from_config(compiler_spec, scope=None):
|
||||||
"""
|
"""
|
||||||
candidate_scopes = [scope]
|
candidate_scopes = [scope]
|
||||||
if scope is None:
|
if scope is None:
|
||||||
candidate_scopes = spack.config.config.scopes.keys()
|
candidate_scopes = spack.config.CONFIG.scopes.keys()
|
||||||
|
|
||||||
removal_happened = False
|
removal_happened = False
|
||||||
for current_scope in candidate_scopes:
|
for current_scope in candidate_scopes:
|
||||||
|
@ -523,7 +523,7 @@ def compiler_for_spec(compiler_spec, arch_spec):
|
||||||
|
|
||||||
@_auto_compiler_spec
|
@_auto_compiler_spec
|
||||||
def get_compiler_duplicates(compiler_spec, arch_spec):
|
def get_compiler_duplicates(compiler_spec, arch_spec):
|
||||||
config = spack.config.config
|
config = spack.config.CONFIG
|
||||||
|
|
||||||
scope_to_compilers = {}
|
scope_to_compilers = {}
|
||||||
for scope in config.scopes:
|
for scope in config.scopes:
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
import spack.abi
|
import spack.abi
|
||||||
import spack.compilers
|
import spack.compilers
|
||||||
|
import spack.config
|
||||||
import spack.environment
|
import spack.environment
|
||||||
import spack.error
|
import spack.error
|
||||||
import spack.platforms
|
import spack.platforms
|
||||||
|
@ -37,7 +38,6 @@
|
||||||
import spack.tengine
|
import spack.tengine
|
||||||
import spack.util.path
|
import spack.util.path
|
||||||
import spack.variant as vt
|
import spack.variant as vt
|
||||||
from spack.config import config
|
|
||||||
from spack.package_prefs import PackagePrefs, is_spec_buildable, spec_externals
|
from spack.package_prefs import PackagePrefs, is_spec_buildable, spec_externals
|
||||||
from spack.version import ClosedOpenRange, VersionList, ver
|
from spack.version import ClosedOpenRange, VersionList, ver
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class Concretizer:
|
||||||
|
|
||||||
def __init__(self, abstract_spec=None):
|
def __init__(self, abstract_spec=None):
|
||||||
if Concretizer.check_for_compiler_existence is None:
|
if Concretizer.check_for_compiler_existence is None:
|
||||||
Concretizer.check_for_compiler_existence = not config.get(
|
Concretizer.check_for_compiler_existence = not spack.config.get(
|
||||||
"config:install_missing_compilers", False
|
"config:install_missing_compilers", False
|
||||||
)
|
)
|
||||||
self.abstract_spec = abstract_spec
|
self.abstract_spec = abstract_spec
|
||||||
|
|
|
@ -47,6 +47,8 @@
|
||||||
import spack.platforms
|
import spack.platforms
|
||||||
import spack.schema
|
import spack.schema
|
||||||
import spack.schema.bootstrap
|
import spack.schema.bootstrap
|
||||||
|
import spack.schema.cdash
|
||||||
|
import spack.schema.ci
|
||||||
import spack.schema.compilers
|
import spack.schema.compilers
|
||||||
import spack.schema.concretizer
|
import spack.schema.concretizer
|
||||||
import spack.schema.config
|
import spack.schema.config
|
||||||
|
@ -64,7 +66,7 @@
|
||||||
from spack.util.cpus import cpus_available
|
from spack.util.cpus import cpus_available
|
||||||
|
|
||||||
#: Dict from section names -> schema for that section
|
#: Dict from section names -> schema for that section
|
||||||
section_schemas = {
|
SECTION_SCHEMAS = {
|
||||||
"compilers": spack.schema.compilers.schema,
|
"compilers": spack.schema.compilers.schema,
|
||||||
"concretizer": spack.schema.concretizer.schema,
|
"concretizer": spack.schema.concretizer.schema,
|
||||||
"mirrors": spack.schema.mirrors.schema,
|
"mirrors": spack.schema.mirrors.schema,
|
||||||
|
@ -80,16 +82,16 @@
|
||||||
|
|
||||||
# Same as above, but including keys for environments
|
# Same as above, but including keys for environments
|
||||||
# this allows us to unify config reading between configs and environments
|
# this allows us to unify config reading between configs and environments
|
||||||
all_schemas = copy.deepcopy(section_schemas)
|
_ALL_SCHEMAS = copy.deepcopy(SECTION_SCHEMAS)
|
||||||
all_schemas.update({spack.schema.env.TOP_LEVEL_KEY: spack.schema.env.schema})
|
_ALL_SCHEMAS.update({spack.schema.env.TOP_LEVEL_KEY: spack.schema.env.schema})
|
||||||
|
|
||||||
#: Path to the default configuration
|
#: Path to the default configuration
|
||||||
configuration_defaults_path = ("defaults", os.path.join(spack.paths.etc_path, "defaults"))
|
CONFIGURATION_DEFAULTS_PATH = ("defaults", os.path.join(spack.paths.etc_path, "defaults"))
|
||||||
|
|
||||||
#: Hard-coded default values for some key configuration options.
|
#: Hard-coded default values for some key configuration options.
|
||||||
#: This ensures that Spack will still work even if config.yaml in
|
#: This ensures that Spack will still work even if config.yaml in
|
||||||
#: the defaults scope is removed.
|
#: the defaults scope is removed.
|
||||||
config_defaults = {
|
CONFIG_DEFAULTS = {
|
||||||
"config": {
|
"config": {
|
||||||
"debug": False,
|
"debug": False,
|
||||||
"connect_timeout": 10,
|
"connect_timeout": 10,
|
||||||
|
@ -105,10 +107,10 @@
|
||||||
|
|
||||||
#: metavar to use for commands that accept scopes
|
#: metavar to use for commands that accept scopes
|
||||||
#: this is shorter and more readable than listing all choices
|
#: this is shorter and more readable than listing all choices
|
||||||
scopes_metavar = "{defaults,system,site,user}[/PLATFORM] or env:ENVIRONMENT"
|
SCOPES_METAVAR = "{defaults,system,site,user}[/PLATFORM] or env:ENVIRONMENT"
|
||||||
|
|
||||||
#: Base name for the (internal) overrides scope.
|
#: Base name for the (internal) overrides scope.
|
||||||
overrides_base_name = "overrides-"
|
_OVERRIDES_BASE_NAME = "overrides-"
|
||||||
|
|
||||||
|
|
||||||
class ConfigScope:
|
class ConfigScope:
|
||||||
|
@ -134,7 +136,7 @@ def get_section_filename(self, section):
|
||||||
def get_section(self, section):
|
def get_section(self, section):
|
||||||
if section not in self.sections:
|
if section not in self.sections:
|
||||||
path = self.get_section_filename(section)
|
path = self.get_section_filename(section)
|
||||||
schema = section_schemas[section]
|
schema = SECTION_SCHEMAS[section]
|
||||||
data = read_config_file(path, schema)
|
data = read_config_file(path, schema)
|
||||||
self.sections[section] = data
|
self.sections[section] = data
|
||||||
return self.sections[section]
|
return self.sections[section]
|
||||||
|
@ -145,7 +147,7 @@ def _write_section(self, section):
|
||||||
|
|
||||||
# We copy data here to avoid adding defaults at write time
|
# We copy data here to avoid adding defaults at write time
|
||||||
validate_data = copy.deepcopy(data)
|
validate_data = copy.deepcopy(data)
|
||||||
validate(validate_data, section_schemas[section])
|
validate(validate_data, SECTION_SCHEMAS[section])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mkdirp(self.path)
|
mkdirp(self.path)
|
||||||
|
@ -317,7 +319,7 @@ def __init__(self, name, data=None):
|
||||||
data = InternalConfigScope._process_dict_keyname_overrides(data)
|
data = InternalConfigScope._process_dict_keyname_overrides(data)
|
||||||
for section in data:
|
for section in data:
|
||||||
dsec = data[section]
|
dsec = data[section]
|
||||||
validate({section: dsec}, section_schemas[section])
|
validate({section: dsec}, SECTION_SCHEMAS[section])
|
||||||
self.sections[section] = _mark_internal(syaml.syaml_dict({section: dsec}), name)
|
self.sections[section] = _mark_internal(syaml.syaml_dict({section: dsec}), name)
|
||||||
|
|
||||||
def get_section_filename(self, section):
|
def get_section_filename(self, section):
|
||||||
|
@ -333,7 +335,7 @@ def _write_section(self, section):
|
||||||
"""This only validates, as the data is already in memory."""
|
"""This only validates, as the data is already in memory."""
|
||||||
data = self.get_section(section)
|
data = self.get_section(section)
|
||||||
if data is not None:
|
if data is not None:
|
||||||
validate(data, section_schemas[section])
|
validate(data, SECTION_SCHEMAS[section])
|
||||||
self.sections[section] = _mark_internal(data, self.name)
|
self.sections[section] = _mark_internal(data, self.name)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -711,11 +713,11 @@ def override(path_or_scope, value=None):
|
||||||
"""
|
"""
|
||||||
if isinstance(path_or_scope, ConfigScope):
|
if isinstance(path_or_scope, ConfigScope):
|
||||||
overrides = path_or_scope
|
overrides = path_or_scope
|
||||||
config.push_scope(path_or_scope)
|
CONFIG.push_scope(path_or_scope)
|
||||||
else:
|
else:
|
||||||
base_name = overrides_base_name
|
base_name = _OVERRIDES_BASE_NAME
|
||||||
# Ensure the new override gets a unique scope name
|
# Ensure the new override gets a unique scope name
|
||||||
current_overrides = [s.name for s in config.matching_scopes(r"^{0}".format(base_name))]
|
current_overrides = [s.name for s in CONFIG.matching_scopes(r"^{0}".format(base_name))]
|
||||||
num_overrides = len(current_overrides)
|
num_overrides = len(current_overrides)
|
||||||
while True:
|
while True:
|
||||||
scope_name = "{0}{1}".format(base_name, num_overrides)
|
scope_name = "{0}{1}".format(base_name, num_overrides)
|
||||||
|
@ -725,19 +727,19 @@ def override(path_or_scope, value=None):
|
||||||
break
|
break
|
||||||
|
|
||||||
overrides = InternalConfigScope(scope_name)
|
overrides = InternalConfigScope(scope_name)
|
||||||
config.push_scope(overrides)
|
CONFIG.push_scope(overrides)
|
||||||
config.set(path_or_scope, value, scope=scope_name)
|
CONFIG.set(path_or_scope, value, scope=scope_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield config
|
yield CONFIG
|
||||||
finally:
|
finally:
|
||||||
scope = config.remove_scope(overrides.name)
|
scope = CONFIG.remove_scope(overrides.name)
|
||||||
assert scope is overrides
|
assert scope is overrides
|
||||||
|
|
||||||
|
|
||||||
#: configuration scopes added on the command line
|
#: configuration scopes added on the command line
|
||||||
#: set by ``spack.main.main()``.
|
#: set by ``spack.main.main()``.
|
||||||
command_line_scopes: List[str] = []
|
COMMAND_LINE_SCOPES: List[str] = []
|
||||||
|
|
||||||
|
|
||||||
def _add_platform_scope(cfg, scope_type, name, path):
|
def _add_platform_scope(cfg, scope_type, name, path):
|
||||||
|
@ -781,14 +783,14 @@ def create():
|
||||||
cfg = Configuration()
|
cfg = Configuration()
|
||||||
|
|
||||||
# first do the builtin, hardcoded defaults
|
# first do the builtin, hardcoded defaults
|
||||||
builtin = InternalConfigScope("_builtin", config_defaults)
|
builtin = InternalConfigScope("_builtin", CONFIG_DEFAULTS)
|
||||||
cfg.push_scope(builtin)
|
cfg.push_scope(builtin)
|
||||||
|
|
||||||
# Builtin paths to configuration files in Spack
|
# Builtin paths to configuration files in Spack
|
||||||
configuration_paths = [
|
configuration_paths = [
|
||||||
# Default configuration scope is the lowest-level scope. These are
|
# Default configuration scope is the lowest-level scope. These are
|
||||||
# versioned with Spack and can be overridden by systems, sites or users
|
# versioned with Spack and can be overridden by systems, sites or users
|
||||||
configuration_defaults_path
|
CONFIGURATION_DEFAULTS_PATH
|
||||||
]
|
]
|
||||||
|
|
||||||
disable_local_config = "SPACK_DISABLE_LOCAL_CONFIG" in os.environ
|
disable_local_config = "SPACK_DISABLE_LOCAL_CONFIG" in os.environ
|
||||||
|
@ -815,7 +817,7 @@ def create():
|
||||||
_add_platform_scope(cfg, ConfigScope, name, path)
|
_add_platform_scope(cfg, ConfigScope, name, path)
|
||||||
|
|
||||||
# add command-line scopes
|
# add command-line scopes
|
||||||
_add_command_line_scopes(cfg, command_line_scopes)
|
_add_command_line_scopes(cfg, COMMAND_LINE_SCOPES)
|
||||||
|
|
||||||
# we make a special scope for spack commands so that they can
|
# we make a special scope for spack commands so that they can
|
||||||
# override configuration options.
|
# override configuration options.
|
||||||
|
@ -825,7 +827,7 @@ def create():
|
||||||
|
|
||||||
|
|
||||||
#: This is the singleton configuration instance for Spack.
|
#: This is the singleton configuration instance for Spack.
|
||||||
config: Union[Configuration, llnl.util.lang.Singleton] = llnl.util.lang.Singleton(create)
|
CONFIG: Union[Configuration, llnl.util.lang.Singleton] = llnl.util.lang.Singleton(create)
|
||||||
|
|
||||||
|
|
||||||
def add_from_file(filename, scope=None):
|
def add_from_file(filename, scope=None):
|
||||||
|
@ -838,7 +840,7 @@ def add_from_file(filename, scope=None):
|
||||||
# update all sections from config dict
|
# update all sections from config dict
|
||||||
# We have to iterate on keys to keep overrides from the file
|
# We have to iterate on keys to keep overrides from the file
|
||||||
for section in data.keys():
|
for section in data.keys():
|
||||||
if section in section_schemas.keys():
|
if section in SECTION_SCHEMAS.keys():
|
||||||
# Special handling for compiler scope difference
|
# Special handling for compiler scope difference
|
||||||
# Has to be handled after we choose a section
|
# Has to be handled after we choose a section
|
||||||
if scope is None:
|
if scope is None:
|
||||||
|
@ -849,7 +851,7 @@ def add_from_file(filename, scope=None):
|
||||||
new = merge_yaml(existing, value)
|
new = merge_yaml(existing, value)
|
||||||
|
|
||||||
# We cannot call config.set directly (set is a type)
|
# We cannot call config.set directly (set is a type)
|
||||||
config.set(section, new, scope)
|
CONFIG.set(section, new, scope)
|
||||||
|
|
||||||
|
|
||||||
def add(fullpath, scope=None):
|
def add(fullpath, scope=None):
|
||||||
|
@ -897,12 +899,12 @@ def add(fullpath, scope=None):
|
||||||
|
|
||||||
# merge value into existing
|
# merge value into existing
|
||||||
new = merge_yaml(existing, value)
|
new = merge_yaml(existing, value)
|
||||||
config.set(path, new, scope)
|
CONFIG.set(path, new, scope)
|
||||||
|
|
||||||
|
|
||||||
def get(path, default=None, scope=None):
|
def get(path, default=None, scope=None):
|
||||||
"""Module-level wrapper for ``Configuration.get()``."""
|
"""Module-level wrapper for ``Configuration.get()``."""
|
||||||
return config.get(path, default, scope)
|
return CONFIG.get(path, default, scope)
|
||||||
|
|
||||||
|
|
||||||
def set(path, value, scope=None):
|
def set(path, value, scope=None):
|
||||||
|
@ -910,26 +912,26 @@ def set(path, value, scope=None):
|
||||||
|
|
||||||
Accepts the path syntax described in ``get()``.
|
Accepts the path syntax described in ``get()``.
|
||||||
"""
|
"""
|
||||||
return config.set(path, value, scope)
|
return CONFIG.set(path, value, scope)
|
||||||
|
|
||||||
|
|
||||||
def add_default_platform_scope(platform):
|
def add_default_platform_scope(platform):
|
||||||
plat_name = os.path.join("defaults", platform)
|
plat_name = os.path.join("defaults", platform)
|
||||||
plat_path = os.path.join(configuration_defaults_path[1], platform)
|
plat_path = os.path.join(CONFIGURATION_DEFAULTS_PATH[1], platform)
|
||||||
config.push_scope(ConfigScope(plat_name, plat_path))
|
CONFIG.push_scope(ConfigScope(plat_name, plat_path))
|
||||||
|
|
||||||
|
|
||||||
def scopes():
|
def scopes():
|
||||||
"""Convenience function to get list of configuration scopes."""
|
"""Convenience function to get list of configuration scopes."""
|
||||||
return config.scopes
|
return CONFIG.scopes
|
||||||
|
|
||||||
|
|
||||||
def _validate_section_name(section):
|
def _validate_section_name(section):
|
||||||
"""Exit if the section is not a valid section."""
|
"""Exit if the section is not a valid section."""
|
||||||
if section not in section_schemas:
|
if section not in SECTION_SCHEMAS:
|
||||||
raise ConfigSectionError(
|
raise ConfigSectionError(
|
||||||
"Invalid config section: '%s'. Options are: %s"
|
"Invalid config section: '%s'. Options are: %s"
|
||||||
% (section, " ".join(section_schemas.keys()))
|
% (section, " ".join(SECTION_SCHEMAS.keys()))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -990,7 +992,7 @@ def read_config_file(filename, schema=None):
|
||||||
if data:
|
if data:
|
||||||
if not schema:
|
if not schema:
|
||||||
key = next(iter(data))
|
key = next(iter(data))
|
||||||
schema = all_schemas[key]
|
schema = _ALL_SCHEMAS[key]
|
||||||
validate(data, schema)
|
validate(data, schema)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -1089,7 +1091,7 @@ def get_valid_type(path):
|
||||||
test_data = {component: test_data}
|
test_data = {component: test_data}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
validate(test_data, section_schemas[section])
|
validate(test_data, SECTION_SCHEMAS[section])
|
||||||
except (ConfigFormatError, AttributeError) as e:
|
except (ConfigFormatError, AttributeError) as e:
|
||||||
jsonschema_error = e.validation_error
|
jsonschema_error = e.validation_error
|
||||||
if jsonschema_error.validator == "type":
|
if jsonschema_error.validator == "type":
|
||||||
|
@ -1278,9 +1280,9 @@ def default_modify_scope(section="config"):
|
||||||
If this is not 'compilers', a general (non-platform) scope is used.
|
If this is not 'compilers', a general (non-platform) scope is used.
|
||||||
"""
|
"""
|
||||||
if section == "compilers":
|
if section == "compilers":
|
||||||
return spack.config.config.highest_precedence_scope().name
|
return CONFIG.highest_precedence_scope().name
|
||||||
else:
|
else:
|
||||||
return spack.config.config.highest_precedence_non_platform_scope().name
|
return CONFIG.highest_precedence_non_platform_scope().name
|
||||||
|
|
||||||
|
|
||||||
def default_list_scope():
|
def default_list_scope():
|
||||||
|
@ -1337,18 +1339,18 @@ def use_configuration(*scopes_or_paths):
|
||||||
Returns:
|
Returns:
|
||||||
Configuration object associated with the scopes passed as arguments
|
Configuration object associated with the scopes passed as arguments
|
||||||
"""
|
"""
|
||||||
global config
|
global CONFIG
|
||||||
|
|
||||||
# Normalize input and construct a Configuration object
|
# Normalize input and construct a Configuration object
|
||||||
configuration = _config_from(scopes_or_paths)
|
configuration = _config_from(scopes_or_paths)
|
||||||
config.clear_caches(), configuration.clear_caches()
|
CONFIG.clear_caches(), configuration.clear_caches()
|
||||||
|
|
||||||
saved_config, config = config, configuration
|
saved_config, CONFIG = CONFIG, configuration
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield configuration
|
yield configuration
|
||||||
finally:
|
finally:
|
||||||
config = saved_config
|
CONFIG = saved_config
|
||||||
|
|
||||||
|
|
||||||
@llnl.util.lang.memoized
|
@llnl.util.lang.memoized
|
||||||
|
|
|
@ -2448,13 +2448,13 @@ def make_repo_path(root):
|
||||||
def prepare_config_scope(env):
|
def prepare_config_scope(env):
|
||||||
"""Add env's scope to the global configuration search path."""
|
"""Add env's scope to the global configuration search path."""
|
||||||
for scope in env.config_scopes():
|
for scope in env.config_scopes():
|
||||||
spack.config.config.push_scope(scope)
|
spack.config.CONFIG.push_scope(scope)
|
||||||
|
|
||||||
|
|
||||||
def deactivate_config_scope(env):
|
def deactivate_config_scope(env):
|
||||||
"""Remove any scopes from env from the global config path."""
|
"""Remove any scopes from env from the global config path."""
|
||||||
for scope in env.config_scopes():
|
for scope in env.config_scopes():
|
||||||
spack.config.config.remove_scope(scope.name)
|
spack.config.CONFIG.remove_scope(scope.name)
|
||||||
|
|
||||||
|
|
||||||
def manifest_file(env_name_or_dir):
|
def manifest_file(env_name_or_dir):
|
||||||
|
|
|
@ -602,10 +602,10 @@ def setup_main_options(args):
|
||||||
|
|
||||||
key = syaml.syaml_str("repos")
|
key = syaml.syaml_str("repos")
|
||||||
key.override = True
|
key.override = True
|
||||||
spack.config.config.scopes["command_line"].sections["repos"] = syaml.syaml_dict(
|
spack.config.CONFIG.scopes["command_line"].sections["repos"] = syaml.syaml_dict(
|
||||||
[(key, [spack.paths.mock_packages_path])]
|
[(key, [spack.paths.mock_packages_path])]
|
||||||
)
|
)
|
||||||
spack.repo.PATH = spack.repo.create(spack.config.config)
|
spack.repo.PATH = spack.repo.create(spack.config.CONFIG)
|
||||||
|
|
||||||
# If the user asked for it, don't check ssl certs.
|
# If the user asked for it, don't check ssl certs.
|
||||||
if args.insecure:
|
if args.insecure:
|
||||||
|
@ -930,7 +930,7 @@ def _main(argv=None):
|
||||||
|
|
||||||
# make spack.config aware of any command line configuration scopes
|
# make spack.config aware of any command line configuration scopes
|
||||||
if args.config_scopes:
|
if args.config_scopes:
|
||||||
spack.config.command_line_scopes = args.config_scopes
|
spack.config.COMMAND_LINE_SCOPES = args.config_scopes
|
||||||
|
|
||||||
# ensure options on spack command come before everything
|
# ensure options on spack command come before everything
|
||||||
setup_main_options(args)
|
setup_main_options(args)
|
||||||
|
|
|
@ -833,7 +833,7 @@ def ensure_modules_are_enabled_or_warn():
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check if we have custom TCL module sections
|
# Check if we have custom TCL module sections
|
||||||
for scope in spack.config.config.file_scopes:
|
for scope in spack.config.CONFIG.file_scopes:
|
||||||
# Skip default configuration
|
# Skip default configuration
|
||||||
if scope.name.startswith("default"):
|
if scope.name.startswith("default"):
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -64,7 +64,7 @@ def use_platform(new_platform):
|
||||||
host = _PickleableCallable(new_platform)
|
host = _PickleableCallable(new_platform)
|
||||||
|
|
||||||
# Clear configuration and compiler caches
|
# Clear configuration and compiler caches
|
||||||
spack.config.config.clear_caches()
|
spack.config.CONFIG.clear_caches()
|
||||||
spack.compilers._cache_config_files = []
|
spack.compilers._cache_config_files = []
|
||||||
|
|
||||||
yield new_platform
|
yield new_platform
|
||||||
|
@ -73,5 +73,5 @@ def use_platform(new_platform):
|
||||||
host = original_host_fn
|
host = original_host_fn
|
||||||
|
|
||||||
# Clear configuration and compiler caches
|
# Clear configuration and compiler caches
|
||||||
spack.config.config.clear_caches()
|
spack.config.CONFIG.clear_caches()
|
||||||
spack.compilers._cache_config_files = []
|
spack.compilers._cache_config_files = []
|
||||||
|
|
|
@ -1357,7 +1357,7 @@ def create_or_construct(path, namespace=None):
|
||||||
|
|
||||||
def _path(configuration=None):
|
def _path(configuration=None):
|
||||||
"""Get the singleton RepoPath instance for Spack."""
|
"""Get the singleton RepoPath instance for Spack."""
|
||||||
configuration = configuration or spack.config.config
|
configuration = configuration or spack.config.CONFIG
|
||||||
return create(configuration=configuration)
|
return create(configuration=configuration)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1404,14 +1404,14 @@ def use_repositories(*paths_and_repos, **kwargs):
|
||||||
paths = [getattr(x, "root", x) for x in paths_and_repos]
|
paths = [getattr(x, "root", x) for x in paths_and_repos]
|
||||||
scope_name = "use-repo-{}".format(uuid.uuid4())
|
scope_name = "use-repo-{}".format(uuid.uuid4())
|
||||||
repos_key = "repos:" if override else "repos"
|
repos_key = "repos:" if override else "repos"
|
||||||
spack.config.config.push_scope(
|
spack.config.CONFIG.push_scope(
|
||||||
spack.config.InternalConfigScope(name=scope_name, data={repos_key: paths})
|
spack.config.InternalConfigScope(name=scope_name, data={repos_key: paths})
|
||||||
)
|
)
|
||||||
PATH, saved = create(configuration=spack.config.config), PATH
|
PATH, saved = create(configuration=spack.config.CONFIG), PATH
|
||||||
try:
|
try:
|
||||||
yield PATH
|
yield PATH
|
||||||
finally:
|
finally:
|
||||||
spack.config.config.remove_scope(scope_name=scope_name)
|
spack.config.CONFIG.remove_scope(scope_name=scope_name)
|
||||||
PATH = saved
|
PATH = saved
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1328,7 +1328,7 @@ def provider_requirements(self):
|
||||||
"Internal Error: possible_virtuals is not populated. Please report to the spack"
|
"Internal Error: possible_virtuals is not populated. Please report to the spack"
|
||||||
" maintainers"
|
" maintainers"
|
||||||
)
|
)
|
||||||
packages_yaml = spack.config.config.get("packages")
|
packages_yaml = spack.config.CONFIG.get("packages")
|
||||||
assert self.possible_virtuals is not None, msg
|
assert self.possible_virtuals is not None, msg
|
||||||
for virtual_str in sorted(self.possible_virtuals):
|
for virtual_str in sorted(self.possible_virtuals):
|
||||||
requirements = packages_yaml.get(virtual_str, {}).get("require", [])
|
requirements = packages_yaml.get(virtual_str, {}).get("require", [])
|
||||||
|
|
|
@ -212,7 +212,7 @@ def create(configuration: ConfigurationType) -> Store:
|
||||||
Args:
|
Args:
|
||||||
configuration: configuration to create a store.
|
configuration: configuration to create a store.
|
||||||
"""
|
"""
|
||||||
configuration = configuration or spack.config.config
|
configuration = configuration or spack.config.CONFIG
|
||||||
config_dict = configuration.get("config")
|
config_dict = configuration.get("config")
|
||||||
root, unpadded_root, projections = parse_install_tree(config_dict)
|
root, unpadded_root, projections = parse_install_tree(config_dict)
|
||||||
hash_length = configuration.get("config:install_hash_length")
|
hash_length = configuration.get("config:install_hash_length")
|
||||||
|
@ -234,7 +234,7 @@ def create(configuration: ConfigurationType) -> Store:
|
||||||
|
|
||||||
|
|
||||||
def _create_global() -> Store:
|
def _create_global() -> Store:
|
||||||
result = create(configuration=spack.config.config)
|
result = create(configuration=spack.config.CONFIG)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -372,10 +372,10 @@ def use_store(
|
||||||
|
|
||||||
# Swap the store with the one just constructed and return it
|
# Swap the store with the one just constructed and return it
|
||||||
ensure_singleton_created()
|
ensure_singleton_created()
|
||||||
spack.config.config.push_scope(
|
spack.config.CONFIG.push_scope(
|
||||||
spack.config.InternalConfigScope(name=scope_name, data={"config": {"install_tree": data}})
|
spack.config.InternalConfigScope(name=scope_name, data={"config": {"install_tree": data}})
|
||||||
)
|
)
|
||||||
temporary_store = create(configuration=spack.config.config)
|
temporary_store = create(configuration=spack.config.CONFIG)
|
||||||
original_store, STORE = STORE, temporary_store
|
original_store, STORE = STORE, temporary_store
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -383,7 +383,7 @@ def use_store(
|
||||||
finally:
|
finally:
|
||||||
# Restore the original store
|
# Restore the original store
|
||||||
STORE = original_store
|
STORE = original_store
|
||||||
spack.config.config.remove_scope(scope_name=scope_name)
|
spack.config.CONFIG.remove_scope(scope_name=scope_name)
|
||||||
|
|
||||||
|
|
||||||
class MatchError(spack.error.SpackError):
|
class MatchError(spack.error.SpackError):
|
||||||
|
|
|
@ -94,14 +94,14 @@ class TestState:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
if _SERIALIZE:
|
if _SERIALIZE:
|
||||||
self.config = spack.config.config
|
self.config = spack.config.CONFIG
|
||||||
self.platform = spack.platforms.host
|
self.platform = spack.platforms.host
|
||||||
self.test_patches = store_patches()
|
self.test_patches = store_patches()
|
||||||
self.store = spack.store.STORE
|
self.store = spack.store.STORE
|
||||||
|
|
||||||
def restore(self):
|
def restore(self):
|
||||||
if _SERIALIZE:
|
if _SERIALIZE:
|
||||||
spack.config.config = self.config
|
spack.config.CONFIG = self.config
|
||||||
spack.repo.PATH = spack.repo.create(self.config)
|
spack.repo.PATH = spack.repo.create(self.config)
|
||||||
spack.platforms.host = self.platform
|
spack.platforms.host = self.platform
|
||||||
spack.store.STORE = self.store
|
spack.store.STORE = self.store
|
||||||
|
|
|
@ -115,8 +115,8 @@ def default_config(tmpdir, config_directory, monkeypatch, install_mockery_mutabl
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
spack.config.config, old_config = cfg, spack.config.config
|
spack.config.CONFIG, old_config = cfg, spack.config.CONFIG
|
||||||
spack.config.config.set("repos", [spack.paths.mock_packages_path])
|
spack.config.CONFIG.set("repos", [spack.paths.mock_packages_path])
|
||||||
njobs = spack.config.get("config:build_jobs")
|
njobs = spack.config.get("config:build_jobs")
|
||||||
if not njobs:
|
if not njobs:
|
||||||
spack.config.set("config:build_jobs", 4, scope="user")
|
spack.config.set("config:build_jobs", 4, scope="user")
|
||||||
|
@ -138,9 +138,9 @@ def default_config(tmpdir, config_directory, monkeypatch, install_mockery_mutabl
|
||||||
if not timeout:
|
if not timeout:
|
||||||
spack.config.set("config:connect_timeout", 10, scope="user")
|
spack.config.set("config:connect_timeout", 10, scope="user")
|
||||||
|
|
||||||
yield spack.config.config
|
yield spack.config.CONFIG
|
||||||
|
|
||||||
spack.config.config = old_config
|
spack.config.CONFIG = old_config
|
||||||
mutable_dir.remove()
|
mutable_dir.remove()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,11 @@ def test_store_is_restored_correctly_after_bootstrap(mutable_config, tmpdir):
|
||||||
user_path = str(tmpdir.join("store"))
|
user_path = str(tmpdir.join("store"))
|
||||||
with spack.store.use_store(user_path):
|
with spack.store.use_store(user_path):
|
||||||
assert spack.store.STORE.root == user_path
|
assert spack.store.STORE.root == user_path
|
||||||
assert spack.config.config.get("config:install_tree:root") == user_path
|
assert spack.config.CONFIG.get("config:install_tree:root") == user_path
|
||||||
with spack.bootstrap.ensure_bootstrap_configuration():
|
with spack.bootstrap.ensure_bootstrap_configuration():
|
||||||
assert spack.store.STORE.root == spack.bootstrap.config.store_path()
|
assert spack.store.STORE.root == spack.bootstrap.config.store_path()
|
||||||
assert spack.store.STORE.root == user_path
|
assert spack.store.STORE.root == user_path
|
||||||
assert spack.config.config.get("config:install_tree:root") == user_path
|
assert spack.config.CONFIG.get("config:install_tree:root") == user_path
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.regression("38963")
|
@pytest.mark.regression("38963")
|
||||||
|
@ -40,11 +40,11 @@ def test_store_padding_length_is_zero_during_bootstrapping(mutable_config, tmpdi
|
||||||
"""
|
"""
|
||||||
user_path = str(tmpdir.join("store"))
|
user_path = str(tmpdir.join("store"))
|
||||||
with spack.store.use_store(user_path, extra_data={"padded_length": 512}):
|
with spack.store.use_store(user_path, extra_data={"padded_length": 512}):
|
||||||
assert spack.config.config.get("config:install_tree:padded_length") == 512
|
assert spack.config.CONFIG.get("config:install_tree:padded_length") == 512
|
||||||
with spack.bootstrap.ensure_bootstrap_configuration():
|
with spack.bootstrap.ensure_bootstrap_configuration():
|
||||||
assert spack.store.STORE.root == spack.bootstrap.config.store_path()
|
assert spack.store.STORE.root == spack.bootstrap.config.store_path()
|
||||||
assert spack.config.config.get("config:install_tree:padded_length") == 0
|
assert spack.config.CONFIG.get("config:install_tree:padded_length") == 0
|
||||||
assert spack.config.config.get("config:install_tree:padded_length") == 512
|
assert spack.config.CONFIG.get("config:install_tree:padded_length") == 512
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.regression("38963")
|
@pytest.mark.regression("38963")
|
||||||
|
@ -54,15 +54,15 @@ def test_install_tree_customization_is_respected(mutable_config, tmp_path):
|
||||||
"""
|
"""
|
||||||
spack.store.reinitialize()
|
spack.store.reinitialize()
|
||||||
store_dir = tmp_path / "store"
|
store_dir = tmp_path / "store"
|
||||||
spack.config.config.set("config:install_tree:root", str(store_dir))
|
spack.config.CONFIG.set("config:install_tree:root", str(store_dir))
|
||||||
with spack.bootstrap.ensure_bootstrap_configuration():
|
with spack.bootstrap.ensure_bootstrap_configuration():
|
||||||
assert spack.store.STORE.root == spack.bootstrap.config.store_path()
|
assert spack.store.STORE.root == spack.bootstrap.config.store_path()
|
||||||
assert (
|
assert (
|
||||||
spack.config.config.get("config:install_tree:root")
|
spack.config.CONFIG.get("config:install_tree:root")
|
||||||
== spack.bootstrap.config.store_path()
|
== spack.bootstrap.config.store_path()
|
||||||
)
|
)
|
||||||
assert spack.config.config.get("config:install_tree:padded_length") == 0
|
assert spack.config.CONFIG.get("config:install_tree:padded_length") == 0
|
||||||
assert spack.config.config.get("config:install_tree:root") == str(store_dir)
|
assert spack.config.CONFIG.get("config:install_tree:root") == str(store_dir)
|
||||||
assert spack.store.STORE.root == str(store_dir)
|
assert spack.store.STORE.root == str(store_dir)
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,12 +185,12 @@ def test_bootstrap_custom_store_in_environment(mutable_config, tmpdir):
|
||||||
|
|
||||||
def test_nested_use_of_context_manager(mutable_config):
|
def test_nested_use_of_context_manager(mutable_config):
|
||||||
"""Test nested use of the context manager"""
|
"""Test nested use of the context manager"""
|
||||||
user_config = spack.config.config
|
user_config = spack.config.CONFIG
|
||||||
with spack.bootstrap.ensure_bootstrap_configuration():
|
with spack.bootstrap.ensure_bootstrap_configuration():
|
||||||
assert spack.config.config != user_config
|
assert spack.config.CONFIG != user_config
|
||||||
with spack.bootstrap.ensure_bootstrap_configuration():
|
with spack.bootstrap.ensure_bootstrap_configuration():
|
||||||
assert spack.config.config != user_config
|
assert spack.config.CONFIG != user_config
|
||||||
assert spack.config.config == user_config
|
assert spack.config.CONFIG == user_config
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("expected_missing", [False, True])
|
@pytest.mark.parametrize("expected_missing", [False, True])
|
||||||
|
|
|
@ -50,7 +50,7 @@ def test_reset_in_file_scopes(mutable_config, scopes):
|
||||||
bootstrap_yaml_files = []
|
bootstrap_yaml_files = []
|
||||||
for s in scopes:
|
for s in scopes:
|
||||||
_bootstrap("disable", "--scope={0}".format(s))
|
_bootstrap("disable", "--scope={0}".format(s))
|
||||||
scope_path = spack.config.config.scopes[s].path
|
scope_path = spack.config.CONFIG.scopes[s].path
|
||||||
bootstrap_yaml = os.path.join(scope_path, "bootstrap.yaml")
|
bootstrap_yaml = os.path.join(scope_path, "bootstrap.yaml")
|
||||||
assert os.path.exists(bootstrap_yaml)
|
assert os.path.exists(bootstrap_yaml)
|
||||||
bootstrap_yaml_files.append(bootstrap_yaml)
|
bootstrap_yaml_files.append(bootstrap_yaml)
|
||||||
|
@ -80,7 +80,7 @@ def test_reset_in_environment(mutable_mock_env_path, mutable_config):
|
||||||
def test_reset_in_file_scopes_overwrites_backup_files(mutable_config):
|
def test_reset_in_file_scopes_overwrites_backup_files(mutable_config):
|
||||||
# Create a bootstrap.yaml with some config
|
# Create a bootstrap.yaml with some config
|
||||||
_bootstrap("disable", "--scope=site")
|
_bootstrap("disable", "--scope=site")
|
||||||
scope_path = spack.config.config.scopes["site"].path
|
scope_path = spack.config.CONFIG.scopes["site"].path
|
||||||
bootstrap_yaml = os.path.join(scope_path, "bootstrap.yaml")
|
bootstrap_yaml = os.path.join(scope_path, "bootstrap.yaml")
|
||||||
assert os.path.exists(bootstrap_yaml)
|
assert os.path.exists(bootstrap_yaml)
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
def _create_config(scope=None, data={}, section="packages"):
|
def _create_config(scope=None, data={}, section="packages"):
|
||||||
scope = scope or spack.config.default_modify_scope()
|
scope = scope or spack.config.default_modify_scope()
|
||||||
cfg_file = spack.config.config.get_config_filename(scope, section)
|
cfg_file = spack.config.CONFIG.get_config_filename(scope, section)
|
||||||
with open(cfg_file, "w") as f:
|
with open(cfg_file, "w") as f:
|
||||||
syaml.dump(data, stream=f)
|
syaml.dump(data, stream=f)
|
||||||
return cfg_file
|
return cfg_file
|
||||||
|
@ -80,8 +80,8 @@ def test_config_edit(mutable_config, working_env):
|
||||||
"""Ensure `spack config edit` edits the right paths."""
|
"""Ensure `spack config edit` edits the right paths."""
|
||||||
|
|
||||||
dms = spack.config.default_modify_scope("compilers")
|
dms = spack.config.default_modify_scope("compilers")
|
||||||
dms_path = spack.config.config.scopes[dms].path
|
dms_path = spack.config.CONFIG.scopes[dms].path
|
||||||
user_path = spack.config.config.scopes["user"].path
|
user_path = spack.config.CONFIG.scopes["user"].path
|
||||||
|
|
||||||
comp_path = os.path.join(dms_path, "compilers.yaml")
|
comp_path = os.path.join(dms_path, "compilers.yaml")
|
||||||
repos_path = os.path.join(user_path, "repos.yaml")
|
repos_path = os.path.join(user_path, "repos.yaml")
|
||||||
|
@ -544,7 +544,7 @@ def test_config_update_not_needed(mutable_config):
|
||||||
def test_config_update_can_handle_comments(mutable_config):
|
def test_config_update_can_handle_comments(mutable_config):
|
||||||
# Create an outdated config file with comments
|
# Create an outdated config file with comments
|
||||||
scope = spack.config.default_modify_scope()
|
scope = spack.config.default_modify_scope()
|
||||||
cfg_file = spack.config.config.get_config_filename(scope, "config")
|
cfg_file = spack.config.CONFIG.get_config_filename(scope, "config")
|
||||||
with open(cfg_file, mode="w") as f:
|
with open(cfg_file, mode="w") as f:
|
||||||
f.write(
|
f.write(
|
||||||
"""
|
"""
|
||||||
|
@ -574,7 +574,7 @@ def test_config_update_can_handle_comments(mutable_config):
|
||||||
@pytest.mark.regression("18050")
|
@pytest.mark.regression("18050")
|
||||||
def test_config_update_works_for_empty_paths(mutable_config):
|
def test_config_update_works_for_empty_paths(mutable_config):
|
||||||
scope = spack.config.default_modify_scope()
|
scope = spack.config.default_modify_scope()
|
||||||
cfg_file = spack.config.config.get_config_filename(scope, "config")
|
cfg_file = spack.config.CONFIG.get_config_filename(scope, "config")
|
||||||
with open(cfg_file, mode="w") as f:
|
with open(cfg_file, mode="w") as f:
|
||||||
f.write(
|
f.write(
|
||||||
"""
|
"""
|
||||||
|
@ -627,7 +627,7 @@ def test_config_prefer_upstream(
|
||||||
|
|
||||||
output = config("prefer-upstream")
|
output = config("prefer-upstream")
|
||||||
scope = spack.config.default_modify_scope("packages")
|
scope = spack.config.default_modify_scope("packages")
|
||||||
cfg_file = spack.config.config.get_config_filename(scope, "packages")
|
cfg_file = spack.config.CONFIG.get_config_filename(scope, "packages")
|
||||||
packages = syaml.load(open(cfg_file))["packages"]
|
packages = syaml.load(open(cfg_file))["packages"]
|
||||||
|
|
||||||
# Make sure only the non-default variants are set.
|
# Make sure only the non-default variants are set.
|
||||||
|
|
|
@ -937,7 +937,7 @@ def test_requires_directive(concretize_scope, mock_packages):
|
||||||
modules: []
|
modules: []
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
spack.config.config.clear_caches()
|
spack.config.CONFIG.clear_caches()
|
||||||
|
|
||||||
# This package requires either clang or gcc
|
# This package requires either clang or gcc
|
||||||
s = Spec("requires_clang_or_gcc").concretized()
|
s = Spec("requires_clang_or_gcc").concretized()
|
||||||
|
|
|
@ -236,7 +236,7 @@ def test_write_key_to_disk(mock_low_high_config, compiler_specs):
|
||||||
spack.config.set("compilers", b_comps["compilers"], scope="high")
|
spack.config.set("compilers", b_comps["compilers"], scope="high")
|
||||||
|
|
||||||
# Clear caches so we're forced to read from disk.
|
# Clear caches so we're forced to read from disk.
|
||||||
spack.config.config.clear_caches()
|
spack.config.CONFIG.clear_caches()
|
||||||
|
|
||||||
# Same check again, to ensure consistency.
|
# Same check again, to ensure consistency.
|
||||||
check_compiler_config(a_comps["compilers"], *compiler_specs.a)
|
check_compiler_config(a_comps["compilers"], *compiler_specs.a)
|
||||||
|
@ -249,7 +249,7 @@ def test_write_to_same_priority_file(mock_low_high_config, compiler_specs):
|
||||||
spack.config.set("compilers", b_comps["compilers"], scope="low")
|
spack.config.set("compilers", b_comps["compilers"], scope="low")
|
||||||
|
|
||||||
# Clear caches so we're forced to read from disk.
|
# Clear caches so we're forced to read from disk.
|
||||||
spack.config.config.clear_caches()
|
spack.config.CONFIG.clear_caches()
|
||||||
|
|
||||||
# Same check again, to ensure consistency.
|
# Same check again, to ensure consistency.
|
||||||
check_compiler_config(a_comps["compilers"], *compiler_specs.a)
|
check_compiler_config(a_comps["compilers"], *compiler_specs.a)
|
||||||
|
@ -369,7 +369,7 @@ def test_substitute_config_variables(mock_low_high_config, monkeypatch):
|
||||||
spack.config.set(
|
spack.config.set(
|
||||||
"modules:default", {"roots": {"lmod": os.path.join("foo", "bar", "baz")}}, scope="low"
|
"modules:default", {"roots": {"lmod": os.path.join("foo", "bar", "baz")}}, scope="low"
|
||||||
)
|
)
|
||||||
spack.config.config.clear_caches()
|
spack.config.CONFIG.clear_caches()
|
||||||
path = spack.config.get("modules:default:roots:lmod")
|
path = spack.config.get("modules:default:roots:lmod")
|
||||||
assert spack_path.canonicalize_path(path) == os.path.normpath(
|
assert spack_path.canonicalize_path(path) == os.path.normpath(
|
||||||
os.path.join(mock_low_high_config.scopes["low"].path, os.path.join("foo", "bar", "baz"))
|
os.path.join(mock_low_high_config.scopes["low"].path, os.path.join("foo", "bar", "baz"))
|
||||||
|
@ -854,18 +854,18 @@ def test_add_command_line_scopes(tmpdir, mutable_config):
|
||||||
|
|
||||||
def test_nested_override():
|
def test_nested_override():
|
||||||
"""Ensure proper scope naming of nested overrides."""
|
"""Ensure proper scope naming of nested overrides."""
|
||||||
base_name = spack.config.overrides_base_name
|
base_name = spack.config._OVERRIDES_BASE_NAME
|
||||||
|
|
||||||
def _check_scopes(num_expected, debug_values):
|
def _check_scopes(num_expected, debug_values):
|
||||||
scope_names = [
|
scope_names = [
|
||||||
s.name for s in spack.config.config.scopes.values() if s.name.startswith(base_name)
|
s.name for s in spack.config.CONFIG.scopes.values() if s.name.startswith(base_name)
|
||||||
]
|
]
|
||||||
|
|
||||||
for i in range(num_expected):
|
for i in range(num_expected):
|
||||||
name = "{0}{1}".format(base_name, i)
|
name = "{0}{1}".format(base_name, i)
|
||||||
assert name in scope_names
|
assert name in scope_names
|
||||||
|
|
||||||
data = spack.config.config.get_config("config", name)
|
data = spack.config.CONFIG.get_config("config", name)
|
||||||
assert data["debug"] == debug_values[i]
|
assert data["debug"] == debug_values[i]
|
||||||
|
|
||||||
# Check results from single and nested override
|
# Check results from single and nested override
|
||||||
|
@ -878,23 +878,23 @@ def _check_scopes(num_expected, debug_values):
|
||||||
|
|
||||||
def test_alternate_override(monkeypatch):
|
def test_alternate_override(monkeypatch):
|
||||||
"""Ensure proper scope naming of override when conflict present."""
|
"""Ensure proper scope naming of override when conflict present."""
|
||||||
base_name = spack.config.overrides_base_name
|
base_name = spack.config._OVERRIDES_BASE_NAME
|
||||||
|
|
||||||
def _matching_scopes(regexpr):
|
def _matching_scopes(regexpr):
|
||||||
return [spack.config.InternalConfigScope("{0}1".format(base_name))]
|
return [spack.config.InternalConfigScope("{0}1".format(base_name))]
|
||||||
|
|
||||||
# Check that the alternate naming works
|
# Check that the alternate naming works
|
||||||
monkeypatch.setattr(spack.config.config, "matching_scopes", _matching_scopes)
|
monkeypatch.setattr(spack.config.CONFIG, "matching_scopes", _matching_scopes)
|
||||||
|
|
||||||
with spack.config.override("config:debug", False):
|
with spack.config.override("config:debug", False):
|
||||||
name = "{0}2".format(base_name)
|
name = "{0}2".format(base_name)
|
||||||
|
|
||||||
scope_names = [
|
scope_names = [
|
||||||
s.name for s in spack.config.config.scopes.values() if s.name.startswith(base_name)
|
s.name for s in spack.config.CONFIG.scopes.values() if s.name.startswith(base_name)
|
||||||
]
|
]
|
||||||
assert name in scope_names
|
assert name in scope_names
|
||||||
|
|
||||||
data = spack.config.config.get_config("config", name)
|
data = spack.config.CONFIG.get_config("config", name)
|
||||||
assert data["debug"] is False
|
assert data["debug"] is False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -716,7 +716,7 @@ def configuration_dir(tmpdir_factory, linux_os):
|
||||||
|
|
||||||
def _create_mock_configuration_scopes(configuration_dir):
|
def _create_mock_configuration_scopes(configuration_dir):
|
||||||
"""Create the configuration scopes used in `config` and `mutable_config`."""
|
"""Create the configuration scopes used in `config` and `mutable_config`."""
|
||||||
scopes = [spack.config.InternalConfigScope("_builtin", spack.config.config_defaults)]
|
scopes = [spack.config.InternalConfigScope("_builtin", spack.config.CONFIG_DEFAULTS)]
|
||||||
scopes += [
|
scopes += [
|
||||||
spack.config.ConfigScope(name, str(configuration_dir.join(name)))
|
spack.config.ConfigScope(name, str(configuration_dir.join(name)))
|
||||||
for name in ["site", "system", "user"]
|
for name in ["site", "system", "user"]
|
||||||
|
@ -1935,7 +1935,7 @@ def shell_as(shell):
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def nullify_globals(request, monkeypatch):
|
def nullify_globals(request, monkeypatch):
|
||||||
ensure_configuration_fixture_run_before(request)
|
ensure_configuration_fixture_run_before(request)
|
||||||
monkeypatch.setattr(spack.config, "config", None)
|
monkeypatch.setattr(spack.config, "CONFIG", None)
|
||||||
monkeypatch.setattr(spack.caches, "misc_cache", None)
|
monkeypatch.setattr(spack.caches, "misc_cache", None)
|
||||||
monkeypatch.setattr(spack.repo, "PATH", None)
|
monkeypatch.setattr(spack.repo, "PATH", None)
|
||||||
monkeypatch.setattr(spack.store, "STORE", None)
|
monkeypatch.setattr(spack.store, "STORE", None)
|
||||||
|
|
|
@ -288,7 +288,7 @@ def install_upstream(tmpdir_factory, gen_mock_layout, install_mockery):
|
||||||
mock_db_root = str(tmpdir_factory.mktemp("mock_db_root"))
|
mock_db_root = str(tmpdir_factory.mktemp("mock_db_root"))
|
||||||
prepared_db = spack.database.Database(mock_db_root)
|
prepared_db = spack.database.Database(mock_db_root)
|
||||||
upstream_layout = gen_mock_layout("/a/")
|
upstream_layout = gen_mock_layout("/a/")
|
||||||
spack.config.config.push_scope(
|
spack.config.CONFIG.push_scope(
|
||||||
spack.config.InternalConfigScope(
|
spack.config.InternalConfigScope(
|
||||||
name="install-upstream-fixture",
|
name="install-upstream-fixture",
|
||||||
data={"upstreams": {"mock1": {"install_tree": prepared_db.root}}},
|
data={"upstreams": {"mock1": {"install_tree": prepared_db.root}}},
|
||||||
|
|
|
@ -39,14 +39,6 @@ def _impl(spec_str, module_set_name="default", explicit=True):
|
||||||
return _impl
|
return _impl
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
|
||||||
def update_template_dirs(config, monkeypatch):
|
|
||||||
"""Mocks the template directories for tests"""
|
|
||||||
dirs = spack.config.get_config("config")["template_dirs"]
|
|
||||||
dirs = [spack.util.path.canonicalize_path(x) for x in dirs]
|
|
||||||
monkeypatch.setattr(spack, "template_dirs", dirs)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def factory(request):
|
def factory(request):
|
||||||
"""Function that, given a spec string, returns an instance of the writer
|
"""Function that, given a spec string, returns an instance of the writer
|
||||||
|
|
Loading…
Reference in a new issue