From 2da34de519c847d86f40ac16734ed4ef9e30c0c8 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Tue, 8 Aug 2023 14:09:55 +0200 Subject: Add "^" automatically for named conflicts that don't refer to 'this' package See https://github.com/spack/spack/pull/38447#discussion_r1285291520 --- lib/spack/spack/directives.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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)) -- cgit v1.2.3-70-g09d2