spec: bump specfile format to v5
Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
parent
7832c56537
commit
403e2db50f
@ -79,7 +79,7 @@
|
|||||||
#: DB version. This is stuck in the DB file to track changes in format.
|
#: DB version. This is stuck in the DB file to track changes in format.
|
||||||
#: Increment by one when the database format changes.
|
#: Increment by one when the database format changes.
|
||||||
#: Versions before 5 were not integers.
|
#: Versions before 5 were not integers.
|
||||||
_DB_VERSION = vn.Version("7")
|
_DB_VERSION = vn.Version("8")
|
||||||
|
|
||||||
#: For any version combinations here, skip reindex when upgrading.
|
#: For any version combinations here, skip reindex when upgrading.
|
||||||
#: Reindexing can take considerable time and is not always necessary.
|
#: Reindexing can take considerable time and is not always necessary.
|
||||||
@ -92,6 +92,8 @@
|
|||||||
(vn.Version("0.9.3"), vn.Version("5")),
|
(vn.Version("0.9.3"), vn.Version("5")),
|
||||||
(vn.Version("5"), vn.Version("6")),
|
(vn.Version("5"), vn.Version("6")),
|
||||||
(vn.Version("6"), vn.Version("7")),
|
(vn.Version("6"), vn.Version("7")),
|
||||||
|
(vn.Version("6"), vn.Version("8")),
|
||||||
|
(vn.Version("7"), vn.Version("8")),
|
||||||
]
|
]
|
||||||
|
|
||||||
#: Default timeout for spack database locks in seconds or None (no timeout).
|
#: Default timeout for spack database locks in seconds or None (no timeout).
|
||||||
@ -140,6 +142,7 @@ def reader(version: vn.StandardVersion) -> Type["spack.spec.SpecfileReaderBase"]
|
|||||||
vn.Version("5"): spack.spec.SpecfileV1,
|
vn.Version("5"): spack.spec.SpecfileV1,
|
||||||
vn.Version("6"): spack.spec.SpecfileV3,
|
vn.Version("6"): spack.spec.SpecfileV3,
|
||||||
vn.Version("7"): spack.spec.SpecfileV4,
|
vn.Version("7"): spack.spec.SpecfileV4,
|
||||||
|
vn.Version("8"): spack.spec.SpecfileV5,
|
||||||
}
|
}
|
||||||
return reader_cls[version]
|
return reader_cls[version]
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
#: specfile format version. Must increase monotonically
|
#: specfile format version. Must increase monotonically
|
||||||
SPECFILE_FORMAT_VERSION = 4
|
SPECFILE_FORMAT_VERSION = 5
|
||||||
|
|
||||||
|
|
||||||
class InstallStatus(enum.Enum):
|
class InstallStatus(enum.Enum):
|
||||||
@ -620,42 +620,11 @@ def complete_with_defaults(self) -> None:
|
|||||||
self.target = default_architecture.target
|
self.target = default_architecture.target
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME (compiler as nodes): remove this class
|
||||||
class CompilerSpec:
|
class CompilerSpec:
|
||||||
"""The CompilerSpec field represents the compiler or range of compiler
|
|
||||||
versions that a package should be built with. CompilerSpecs have a
|
|
||||||
name and a version list."""
|
|
||||||
|
|
||||||
__slots__ = "name", "versions"
|
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
raise SystemExit("CompilerSpec is being removed")
|
raise SystemExit("CompilerSpec is being removed")
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def from_dict(d):
|
|
||||||
d = d["compiler"]
|
|
||||||
return Spec(
|
|
||||||
f"{d['name']}@{vn.VersionList.from_dict(d)}", external_path="/dev-null/", concrete=True
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def display_str(self):
|
|
||||||
"""Equivalent to {compiler.name}{@compiler.version} for Specs, without extra
|
|
||||||
@= for readability."""
|
|
||||||
if self.concrete:
|
|
||||||
return f"{self.name}@{self.version}"
|
|
||||||
elif self.versions != vn.any_version:
|
|
||||||
return f"{self.name}@{self.versions}"
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
out = self.name
|
|
||||||
if self.versions and self.versions != vn.any_version:
|
|
||||||
out += f"@{self.versions}"
|
|
||||||
return out
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return str(self)
|
|
||||||
|
|
||||||
|
|
||||||
@lang.lazy_lexicographic_ordering
|
@lang.lazy_lexicographic_ordering
|
||||||
class DependencySpec:
|
class DependencySpec:
|
||||||
@ -2625,8 +2594,10 @@ def from_dict(data):
|
|||||||
spec = SpecfileV2.load(data)
|
spec = SpecfileV2.load(data)
|
||||||
elif int(data["spec"]["_meta"]["version"]) == 3:
|
elif int(data["spec"]["_meta"]["version"]) == 3:
|
||||||
spec = SpecfileV3.load(data)
|
spec = SpecfileV3.load(data)
|
||||||
else:
|
elif int(data["spec"]["_meta"]["version"]) == 4:
|
||||||
spec = SpecfileV4.load(data)
|
spec = SpecfileV4.load(data)
|
||||||
|
else:
|
||||||
|
spec = SpecfileV5.load(data)
|
||||||
|
|
||||||
# Any git version should
|
# Any git version should
|
||||||
for s in spec.traverse():
|
for s in spec.traverse():
|
||||||
@ -4825,7 +4796,7 @@ def from_node_dict(cls, node):
|
|||||||
|
|
||||||
if "compiler" in node:
|
if "compiler" in node:
|
||||||
# Annotate the compiler spec, might be used later
|
# Annotate the compiler spec, might be used later
|
||||||
spec.compiler_annotation = CompilerSpec.from_dict(node)
|
spec.compiler_annotation = cls.legacy_compiler(node)
|
||||||
|
|
||||||
propagated_names = node.get("propagate", [])
|
propagated_names = node.get("propagate", [])
|
||||||
for name, values in node.get("parameters", {}).items():
|
for name, values in node.get("parameters", {}).items():
|
||||||
@ -4873,6 +4844,13 @@ def from_node_dict(cls, node):
|
|||||||
|
|
||||||
return spec
|
return spec
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def legacy_compiler(cls, node):
|
||||||
|
d = node["compiler"]
|
||||||
|
return Spec(
|
||||||
|
f"{d['name']}@{vn.VersionList.from_dict(d)}", external_path="/dev-null/", concrete=True
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _load(cls, data):
|
def _load(cls, data):
|
||||||
"""Construct a spec from JSON/YAML using the format version 2.
|
"""Construct a spec from JSON/YAML using the format version 2.
|
||||||
@ -5079,6 +5057,12 @@ def load(cls, data):
|
|||||||
return cls._load(data)
|
return cls._load(data)
|
||||||
|
|
||||||
|
|
||||||
|
class SpecfileV5(SpecfileV4):
|
||||||
|
@classmethod
|
||||||
|
def legacy_compiler(cls, node):
|
||||||
|
raise RuntimeError("The 'compiler' option is unexpected in specfiles at v5 or greater")
|
||||||
|
|
||||||
|
|
||||||
class LazySpecCache(collections.defaultdict):
|
class LazySpecCache(collections.defaultdict):
|
||||||
"""Cache for Specs that uses a spec_like as key, and computes lazily
|
"""Cache for Specs that uses a spec_like as key, and computes lazily
|
||||||
the corresponding value ``Spec(spec_like``.
|
the corresponding value ``Spec(spec_like``.
|
||||||
|
Loading…
Reference in New Issue
Block a user