From da4f7c2952e4dcc9f0581db2fac43da13b0bcb47 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Sun, 17 Nov 2024 21:32:24 +0100 Subject: [PATCH] Add an audit to prevent using the name "all" in packages (#47651) Packages cannot be named like that, since we use "all" to indicate default settings under the "packages" section of the configuration. --- lib/spack/spack/audit.py | 5 +++++ .../repos/builtin/packages/{all => all-library}/package.py | 2 +- var/spack/repos/builtin/packages/cabana/package.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) rename var/spack/repos/builtin/packages/{all => all-library}/package.py (98%) diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py index 273e335ade03cf..7e6b87c987c613 100644 --- a/lib/spack/spack/audit.py +++ b/lib/spack/spack/audit.py @@ -571,8 +571,13 @@ def _search_for_deprecated_package_methods(pkgs, error_cls): @package_properties def _ensure_all_package_names_are_lowercase(pkgs, error_cls): """Ensure package names are lowercase and consistent""" + reserved_names = ("all",) badname_regex, errors = re.compile(r"[_A-Z]"), [] for pkg_name in pkgs: + if pkg_name in reserved_names: + error_msg = f"The name '{pkg_name}' is reserved, and cannot be used for packages" + errors.append(error_cls(error_msg, [])) + if badname_regex.search(pkg_name): error_msg = f"Package name '{pkg_name}' should be lowercase and must not contain '_'" errors.append(error_cls(error_msg, [])) diff --git a/var/spack/repos/builtin/packages/all/package.py b/var/spack/repos/builtin/packages/all-library/package.py similarity index 98% rename from var/spack/repos/builtin/packages/all/package.py rename to var/spack/repos/builtin/packages/all-library/package.py index c30254cc95c4e1..8841584194b591 100644 --- a/var/spack/repos/builtin/packages/all/package.py +++ b/var/spack/repos/builtin/packages/all-library/package.py @@ -6,7 +6,7 @@ from spack.package import * -class All(CMakePackage): +class AllLibrary(CMakePackage): """A Load Balancing Library (ALL) The library aims to provide an easy way to include dynamic domain-based diff --git a/var/spack/repos/builtin/packages/cabana/package.py b/var/spack/repos/builtin/packages/cabana/package.py index 42852dc12320c0..3905b30b294afe 100644 --- a/var/spack/repos/builtin/packages/cabana/package.py +++ b/var/spack/repos/builtin/packages/cabana/package.py @@ -93,7 +93,7 @@ class Cabana(CMakePackage, CudaPackage, ROCmPackage): depends_on("kokkos+cuda_lambda@4.1:", when="+cuda@0.7:") # Dependencies for subpackages - depends_on("all", when="@0.5.0:+all") + depends_on("all-library", when="@0.5.0:+all") depends_on("arborx", when="@0.3.0:+arborx") depends_on("hypre-cmake@2.22.0:", when="@0.4.0:+hypre") depends_on("hypre-cmake@2.22.1:", when="@0.5.0:+hypre")