Spec.validate_detection -> spack.detection.path.validate_detection (#48987)
This commit is contained in:
parent
03e972314f
commit
a137da1cd5
@ -259,6 +259,8 @@ def detect_specs(
|
|||||||
)
|
)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
from spack.repo import PATH as repo_path
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
for candidate_path, items_in_prefix in _group_by_prefix(
|
for candidate_path, items_in_prefix in _group_by_prefix(
|
||||||
llnl.util.lang.dedupe(paths)
|
llnl.util.lang.dedupe(paths)
|
||||||
@ -305,7 +307,10 @@ def detect_specs(
|
|||||||
|
|
||||||
resolved_specs[spec] = candidate_path
|
resolved_specs[spec] = candidate_path
|
||||||
try:
|
try:
|
||||||
spec.validate_detection()
|
# Validate the spec calling a package specific method
|
||||||
|
pkg_cls = repo_path.get_pkg_class(spec.name)
|
||||||
|
validate_fn = getattr(pkg_cls, "validate_detected_spec", lambda x, y: None)
|
||||||
|
validate_fn(spec, spec.extra_attributes)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = (
|
msg = (
|
||||||
f'"{spec}" has been detected on the system but will '
|
f'"{spec}" has been detected on the system but will '
|
||||||
|
@ -2826,24 +2826,6 @@ def from_detection(
|
|||||||
s.extra_attributes = extra_attributes
|
s.extra_attributes = extra_attributes
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def validate_detection(self):
|
|
||||||
"""Validate the detection of an external spec.
|
|
||||||
|
|
||||||
This method is used as part of Spack's detection protocol, and is
|
|
||||||
not meant for client code use.
|
|
||||||
"""
|
|
||||||
# Assert that _extra_attributes is a Mapping and not None,
|
|
||||||
# which likely means the spec was created with Spec.from_detection
|
|
||||||
msg = 'cannot validate "{0}" since it was not created ' "using Spec.from_detection".format(
|
|
||||||
self
|
|
||||||
)
|
|
||||||
assert isinstance(self.extra_attributes, collections.abc.Mapping), msg
|
|
||||||
|
|
||||||
# Validate the spec calling a package specific method
|
|
||||||
pkg_cls = spack.repo.PATH.get_pkg_class(self.name)
|
|
||||||
validate_fn = getattr(pkg_cls, "validate_detected_spec", lambda x, y: None)
|
|
||||||
validate_fn(self, self.extra_attributes)
|
|
||||||
|
|
||||||
def _patches_assigned(self):
|
def _patches_assigned(self):
|
||||||
"""Whether patches have been assigned to this spec by the concretizer."""
|
"""Whether patches have been assigned to this spec by the concretizer."""
|
||||||
# FIXME: _patches_in_order_of_appearance is attached after concretization
|
# FIXME: _patches_in_order_of_appearance is attached after concretization
|
||||||
|
Loading…
Reference in New Issue
Block a user