diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2023-12-07 10:21:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-07 10:21:01 +0100 |
commit | 31640652c7b5e1a430ab7dfb894347aff96cddd7 (patch) | |
tree | 8b0b8c9070b711cad1e5f6bcb33de60c191cbcb6 /lib | |
parent | 0ff0e8944ec97b3dd3e47ea2a6224ad3095448ed (diff) | |
download | spack-31640652c7b5e1a430ab7dfb894347aff96cddd7.tar.gz spack-31640652c7b5e1a430ab7dfb894347aff96cddd7.tar.bz2 spack-31640652c7b5e1a430ab7dfb894347aff96cddd7.tar.xz spack-31640652c7b5e1a430ab7dfb894347aff96cddd7.zip |
audit: forbid nested dependencies in depends_on declarations (#41428)
Forbid nested dependencies in depends_on declarations, by running an audit in CI.
Fix the packages not passing the new audit:
- amd-aocl
- exago
- palace
- shapemapper
- xsdk-examples
ginkgo: add a commit sha to v1.5.0.glu_experimental
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/audit.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py index 970e4a3b36..4fe1b1dddf 100644 --- a/lib/spack/spack/audit.py +++ b/lib/spack/spack/audit.py @@ -726,13 +726,37 @@ def _unknown_variants_in_directives(pkgs, error_cls): @package_directives -def _unknown_variants_in_dependencies(pkgs, error_cls): - """Report unknown dependencies and wrong variants for dependencies""" +def _issues_in_depends_on_directive(pkgs, error_cls): + """Reports issues with 'depends_on' directives. + + Issues might be unknown dependencies, unknown variants or variant values, or declaration + of nested dependencies. + """ errors = [] for pkg_name in pkgs: pkg_cls = spack.repo.PATH.get_pkg_class(pkg_name) filename = spack.repo.PATH.filename_for_package_name(pkg_name) for dependency_name, dependency_data in pkg_cls.dependencies.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. + for when, dependency_edge in dependency_data.items(): + dependency_spec = dependency_edge.spec + nested_dependencies = dependency_spec.dependencies() + if nested_dependencies: + summary = ( + f"{pkg_name}: invalid nested dependency " + f"declaration '{str(dependency_spec)}'" + ) + details = [ + f"split depends_on('{str(dependency_spec)}', when='{str(when)}') " + f"into {len(nested_dependencies) + 1} directives", + f"in {filename}", + ] + errors.append(error_cls(summary=summary, details=details)) + # No need to analyze virtual packages if spack.repo.PATH.is_virtual(dependency_name): continue |