spack audit: allow skipping version checks from package.py (#28372)

A few packages have version directives evaluated
within if statements, conditional on the value of
`platform.platform()`.

Sometimes there are no cases for e.g. platform=darwin and that
causes a lot of spurious failures with version existence
audits.

This PR allows expressing conditions to skip version
existence checks in audits and avoid these spurious reports.
This commit is contained in:
Massimiliano Culpo
2023-07-13 12:47:47 +02:00
committed by GitHub
parent 161b30a32f
commit 3261889e3a
10 changed files with 31 additions and 5 deletions

View File

@@ -725,11 +725,22 @@ def _version_constraints_are_satisfiable_by_some_version_in_repo(pkgs, error_cls
dependencies_to_check.extend([edge.spec for edge in dependency_data.values()])
host_architecture = spack.spec.ArchSpec.default_arch()
for s in dependencies_to_check:
dependency_pkg_cls = None
try:
dependency_pkg_cls = spack.repo.path.get_pkg_class(s.name)
assert any(v.intersects(s.versions) for v in list(dependency_pkg_cls.versions))
# Some packages have hacks that might cause failures on some platform
# Allow to explicitly set conditions to skip version checks in that case
skip_conditions = getattr(dependency_pkg_cls, "skip_version_audit", [])
skip_version_check = False
for condition in skip_conditions:
if host_architecture.satisfies(spack.spec.Spec(condition).architecture):
skip_version_check = True
break
assert skip_version_check or any(
v.intersects(s.versions) for v in list(dependency_pkg_cls.versions)
)
except Exception:
summary = (
"{0}: dependency on {1} cannot be satisfied " "by known versions of {1.name}"