summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2022-11-28 10:03:49 -0800
committerGitHub <noreply@github.com>2022-11-28 10:03:49 -0800
commit451e3ff50b631ae0597d2223aa7be2da4222fc33 (patch)
tree31ec29c567c0be0d0f58de46a686a6cb1893f4a6
parent523c4c2b63bdca0d649b13859c528531b6d4b6c9 (diff)
downloadspack-451e3ff50b631ae0597d2223aa7be2da4222fc33.tar.gz
spack-451e3ff50b631ae0597d2223aa7be2da4222fc33.tar.bz2
spack-451e3ff50b631ae0597d2223aa7be2da4222fc33.tar.xz
spack-451e3ff50b631ae0597d2223aa7be2da4222fc33.zip
warn about removal of deprecated format strings (#34101)
* warn about removal of deprecated format strings Co-authored-by: becker33 <becker33@users.noreply.github.com>
-rw-r--r--etc/spack/defaults/config.yaml3
-rw-r--r--lib/spack/spack/spec.py9
-rw-r--r--lib/spack/spack/test/config.py7
-rw-r--r--lib/spack/spack/test/directory_layout.py2
-rw-r--r--lib/spack/spack/test/util/spack_yaml.py1
-rw-r--r--share/spack/qa/configuration/windows_config.yaml4
6 files changed, 19 insertions, 7 deletions
diff --git a/etc/spack/defaults/config.yaml b/etc/spack/defaults/config.yaml
index 0bf52a0e55..f42a6525e2 100644
--- a/etc/spack/defaults/config.yaml
+++ b/etc/spack/defaults/config.yaml
@@ -19,7 +19,7 @@ config:
install_tree:
root: $spack/opt/spack
projections:
- all: "${ARCHITECTURE}/${COMPILERNAME}-${COMPILERVER}/${PACKAGE}-${VERSION}-${HASH}"
+ all: "{architecture}/{compiler.name}-{compiler.version}/{name}-{version}-{hash}"
# install_tree can include an optional padded length (int or boolean)
# default is False (do not pad)
# if padded_length is True, Spack will pad as close to the system max path
@@ -219,4 +219,3 @@ config:
flags:
# Whether to keep -Werror flags active in package builds.
keep_werror: 'none'
-
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 5c688d916f..742f3bd652 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -4332,7 +4332,9 @@ class Spec(object):
attribute += c
else:
if c == "}":
- raise SpecFormatStringError("Encountered closing } before opening {")
+ raise SpecFormatStringError(
+ "Encountered closing } before opening { in %s" % format_string
+ )
elif c == "{":
in_attribute = True
else:
@@ -4418,7 +4420,10 @@ class Spec(object):
TODO: allow, e.g., ``$6#`` to customize short hash length
TODO: allow, e.g., ``$//`` for full hash.
"""
-
+ warnings.warn(
+ "Using the old Spec.format method."
+ " This method was deprecated in Spack v0.15 and will be removed in Spack v0.20"
+ )
color = kwargs.get("color", False)
# Dictionary of transformations for named tokens
diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py
index e310519afd..a9c0475804 100644
--- a/lib/spack/spack/test/config.py
+++ b/lib/spack/spack/test/config.py
@@ -1254,6 +1254,13 @@ def test_user_config_path_is_default_when_env_var_is_empty(working_env):
assert os.path.expanduser("~%s.spack" % os.sep) == spack.paths._get_user_config_path()
+def test_default_install_tree(monkeypatch):
+ s = spack.spec.Spec("nonexistent@x.y.z %none@a.b.c arch=foo-bar-baz")
+ monkeypatch.setattr(s, "dag_hash", lambda: "abc123")
+ projection = spack.config.get("config:install_tree:projections:all", scope="defaults")
+ assert s.format(projection) == "foo-bar-baz/none-a.b.c/nonexistent-x.y.z-abc123"
+
+
def test_local_config_can_be_disabled(working_env):
os.environ["SPACK_DISABLE_LOCAL_CONFIG"] = "true"
cfg = spack.config._config()
diff --git a/lib/spack/spack/test/directory_layout.py b/lib/spack/spack/test/directory_layout.py
index 86d160c5cc..7b18183f67 100644
--- a/lib/spack/spack/test/directory_layout.py
+++ b/lib/spack/spack/test/directory_layout.py
@@ -59,7 +59,7 @@ def test_yaml_directory_layout_parameters(tmpdir, default_mock_concretization):
arch_scheme = (
"{architecture.platform}/{architecture.target}/{architecture.os}/{name}/{version}/{hash:7}"
)
- ns_scheme = "${ARCHITECTURE}/${NAMESPACE}/${PACKAGE}-${VERSION}-${HASH:7}"
+ ns_scheme = "{architecture}/{namespace}/{name}-{version}-{hash:7}"
arch_ns_scheme_projections = {"all": arch_scheme, "python": ns_scheme}
layout_arch_ns = DirectoryLayout(str(tmpdir), projections=arch_ns_scheme_projections)
diff --git a/lib/spack/spack/test/util/spack_yaml.py b/lib/spack/spack/test/util/spack_yaml.py
index 600c6d5bef..6a30129b02 100644
--- a/lib/spack/spack/test/util/spack_yaml.py
+++ b/lib/spack/spack/test/util/spack_yaml.py
@@ -86,6 +86,7 @@ def test_config_blame_defaults():
if match:
filename, line, key, val = match.groups()
line = int(line)
+ val = val.strip("'\"")
if val.lower() in ("true", "false"):
val = val.lower()
diff --git a/share/spack/qa/configuration/windows_config.yaml b/share/spack/qa/configuration/windows_config.yaml
index fb90000223..85625cf49b 100644
--- a/share/spack/qa/configuration/windows_config.yaml
+++ b/share/spack/qa/configuration/windows_config.yaml
@@ -3,6 +3,6 @@ config:
install_tree:
root: $spack\opt\spack
projections:
- all: '${ARCHITECTURE}\${COMPILERNAME}-${COMPILERVER}\${PACKAGE}-${VERSION}-${HASH}'
+ all: '{architecture}\\{compiler.name}-{compiler.version}\\{name}-{version}-{hash}'
build_stage:
- - ~/.spack/stage \ No newline at end of file
+ - ~/.spack/stage