Skip to content
Snippets Groups Projects
Commit aff0e8b5 authored by Todd Gamblin's avatar Todd Gamblin
Browse files

architecture: make it easier to get a Spec for the default arch

- [x] Make it easier to get a `Spec` with a proper `ArchSpec` from an
      `Arch` object via new `Arch.to_spec()` method.

- [x] Pull `spack.architecture.default_arch()` out of
      `spack.architecture.sys_type()` so we can get an `Arch` instead of
      a string.
parent 7302dd83
Branches
Tags
No related merge requests found
...@@ -436,6 +436,12 @@ def to_dict(self): ...@@ -436,6 +436,12 @@ def to_dict(self):
('target', self.target.to_dict_or_value())]) ('target', self.target.to_dict_or_value())])
return syaml_dict([('arch', d)]) return syaml_dict([('arch', d)])
def to_spec(self):
"""Convert this Arch to an anonymous Spec with architecture defined."""
spec = spack.spec.Spec()
spec.architecture = spack.spec.ArchSpec(str(self))
return spec
@staticmethod @staticmethod
def from_dict(d): def from_dict(d):
spec = spack.spec.ArchSpec.from_dict(d) spec = spack.spec.ArchSpec.from_dict(d)
...@@ -518,6 +524,14 @@ def platform(): ...@@ -518,6 +524,14 @@ def platform():
@memoized @memoized
def default_arch():
"""Default ``Arch`` object for this machine.
See ``sys_type()``.
"""
return Arch(platform(), 'default_os', 'default_target')
def sys_type(): def sys_type():
"""Print out the "default" platform-os-target tuple for this machine. """Print out the "default" platform-os-target tuple for this machine.
...@@ -530,8 +544,7 @@ def sys_type(): ...@@ -530,8 +544,7 @@ def sys_type():
architectures. architectures.
""" """
arch = Arch(platform(), 'default_os', 'default_target') return str(default_arch())
return str(arch)
@memoized @memoized
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment