Skip to content

Serialized copies of specs do not correctly report is_extension #3887

@scheibelp

Description

@scheibelp

If a spec is written to yaml and then read back, it's dependencies do not correctly report .is_extension:

>>> from spack.spec import Spec
>>> x = Spec('git')
>>> x.concretize()
>>> y = Spec.from_dict(x.to_dict())
>>> y['libxml2'].package.is_extension
True
>>> x['libxml2'].package.is_extension
False

(Spec.to_yaml and Spec.from_yaml use the corresponding dict functions, so this affects specs that have been read from files).

Note that using Spec.copy() does not have this problem.

Two notes:

  • Specs constructed with Spec.from_dict have _concrete set to False (although concrete is true if the original Spec was concrete)
  • Package.is_extension refers to Spec._concrete

This suggests the following possible solutions:

  • Package.is_extension uses Spec.concrete instead of Spec._concrete. This is done in Package.is_extension now uses Spec.concrete #3853 and has some (IMO valid) criticisms that the repercussions need to be clarified
  • Spec.from_dict should set _concrete (perhaps if it doesn't change after concretization)
  • Spec.to_dict should record whether the spec was concrete

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions