Make use of ^ in 'depends_on' an error (#48062)

The use of `^` in `depends_on` directives has never been allowed, since
the dawn of Spack.

Up to now, we used to have an audit to catch this kind of issue, mainly
because in that way we could easily collect all issues and report them
to packagers at once.

Due to implementation details, this audit doesn't work if a dependency
without a `^` is followed by the same dependency with a `^`.

This PR makes this pattern an error, which will be reported eagerly, and
removes the corresponding audit. It also fixes a package using the wrong
idiom.

Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
This commit is contained in:
Massimiliano Culpo 2024-12-12 14:19:05 +01:00 committed by GitHub
parent 0ce38ed109
commit 7105cc8c01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 17 deletions

View File

@ -1009,20 +1009,6 @@ def _issues_in_depends_on_directive(pkgs, error_cls):
for when, deps_by_name in pkg_cls.dependencies.items():
for dep_name, dep in deps_by_name.items():
# Check if there are nested dependencies declared. We don't want directives like:
#
# depends_on('foo+bar ^fee+baz')
#
# but we'd like to have two dependencies listed instead.
nested_dependencies = dep.spec.dependencies()
if nested_dependencies:
summary = f"{pkg_name}: nested dependency declaration '{dep.spec}'"
ndir = len(nested_dependencies) + 1
details = [
f"split depends_on('{dep.spec}', when='{when}') into {ndir} directives",
f"in {filename}",
]
errors.append(error_cls(summary=summary, details=details))
def check_virtual_with_variants(spec, msg):
if not spec.virtual or not spec.variants:

View File

@ -297,6 +297,13 @@ def _depends_on(
deps_by_name = pkg.dependencies.setdefault(when_spec, {})
dependency = deps_by_name.get(spec.name)
if spec.dependencies():
raise DirectiveError(
f"the '^' sigil cannot be used in 'depends_on' directives. Please reformulate "
f"the directive below as multiple directives:\n\n"
f'\tdepends_on("{spec}", when="{when_spec}")\n'
)
if not dependency:
dependency = Dependency(pkg, spec, depflag=depflag)
deps_by_name[spec.name] = dependency

View File

@ -35,6 +35,14 @@ class AmdAocl(BundlePackage):
variant("openmp", default=False, description="Enable OpenMP support.")
depends_on("scalapack")
depends_on("lapack")
depends_on("blas")
requires("^[virtuals=scalapack] amdscalapack")
requires("^[virtuals=lapack] amdlibflame")
requires("^[virtuals=blas] amdblis")
with when("+openmp"):
depends_on("amdblis threads=openmp")
depends_on("amdfftw +openmp")
@ -56,11 +64,8 @@ class AmdAocl(BundlePackage):
depends_on(f"amdblis@={vers}")
depends_on(f"amdfftw@={vers}")
depends_on(f"amdlibflame@={vers}")
depends_on("amdlibflame ^[virtuals=blas] amdblis")
depends_on(f"amdlibm@={vers}")
depends_on(f"amdscalapack@={vers}")
depends_on("amdscalapack ^[virtuals=blas] amdblis")
depends_on("amdscalapack ^[virtuals=lapack] amdlibflame")
depends_on(f"aocl-sparse@={vers}")
if Version(vers) >= Version("4.2"):
depends_on(f"aocl-compression@={vers}")