diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 3b9dd438df9..2fa1bffe85b 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -2173,10 +2173,7 @@ def to_node_dict(self, hash=ht.dag_hash): if self.namespace: d["namespace"] = self.namespace - # Get all variants *except* for patches. Patches are included in "artifacts" below. - params = syaml.syaml_dict( - sorted(v.yaml_entry() for _, v in self.variants.items() if v.name != "patches") - ) + params = syaml.syaml_dict(sorted(v.yaml_entry() for _, v in self.variants.items())) # Only need the string compiler flag for yaml file params.update( @@ -2201,6 +2198,11 @@ def to_node_dict(self, hash=ht.dag_hash): if not self._concrete: d["concrete"] = False + if "patches" in self.variants: + variant = self.variants["patches"] + if hasattr(variant, "_patches_in_order_of_appearance"): + d["patches"] = variant._patches_in_order_of_appearance + if self._concrete and hash.package_hash: # We use the `_package_hash` attribute here instead of `self.package_hash()` # because `_package_hash` is *always* assigned at concretization time. If