summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2023-08-08 14:09:55 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2023-08-15 15:54:37 -0700
commit2da34de519c847d86f40ac16734ed4ef9e30c0c8 (patch)
tree5a09d24685ec7f0a7311d19f1c3062785cc72980 /lib
parentd237430f47a620cdc0a5137efb8b63d49a92b007 (diff)
downloadspack-2da34de519c847d86f40ac16734ed4ef9e30c0c8.tar.gz
spack-2da34de519c847d86f40ac16734ed4ef9e30c0c8.tar.bz2
spack-2da34de519c847d86f40ac16734ed4ef9e30c0c8.tar.xz
spack-2da34de519c847d86f40ac16734ed4ef9e30c0c8.zip
Add "^" automatically for named conflicts that don't refer to 'this' package
See https://github.com/spack/spack/pull/38447#discussion_r1285291520
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/directives.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py
index acb2af1a62..2b7aefca55 100644
--- a/lib/spack/spack/directives.py
+++ b/lib/spack/spack/directives.py
@@ -33,6 +33,7 @@ import collections.abc
import functools
import os.path
import re
+import warnings
from typing import Any, Callable, List, Optional, Set, Tuple, Union
import llnl.util.lang
@@ -518,8 +519,20 @@ def conflicts(conflict_spec, when=None, msg=None):
if not when_spec:
return
+ # TODO: (remove after v0.21)
+ conflict_key = conflict_spec
+ s = spack.spec.Spec(conflict_spec)
+ if s.name and s.name != pkg.name:
+ warning_msg = (
+ f"the conflict in package '{pkg.name}' on '{conflict_spec}' should "
+ f"start with a '^' sigil. Not using it is deprecated as of v0.21 and"
+ f" will be disallowed in v0.22"
+ )
+ warnings.warn(warning_msg)
+ conflict_key = "^" + conflict_spec
+
# Save in a list the conflicts and the associated custom messages
- when_spec_list = pkg.conflicts.setdefault(conflict_spec, [])
+ when_spec_list = pkg.conflicts.setdefault(conflict_key, [])
msg_with_name = f"{pkg.name}: {msg}" if msg is not None else msg
when_spec_list.append((when_spec, msg_with_name))