diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2020-07-31 18:51:12 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2020-08-01 08:36:12 -0700 |
commit | 0c48f0a15dc63129aa2bdc146152a9bf1c32e66e (patch) | |
tree | bea67f9a1964fb4a4328c86d46f31362fb3dcaa6 /lib | |
parent | c65cde4cf8b718625cce2200f8bbffd0283a54eb (diff) | |
download | spack-0c48f0a15dc63129aa2bdc146152a9bf1c32e66e.tar.gz spack-0c48f0a15dc63129aa2bdc146152a9bf1c32e66e.tar.bz2 spack-0c48f0a15dc63129aa2bdc146152a9bf1c32e66e.tar.xz spack-0c48f0a15dc63129aa2bdc146152a9bf1c32e66e.zip |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/architecture.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py index 963fecd375..a7c8062fad 100644 --- a/lib/spack/spack/architecture.py +++ b/lib/spack/spack/architecture.py @@ -436,6 +436,12 @@ class Arch(object): ('target', self.target.to_dict_or_value())]) 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 def from_dict(d): spec = spack.spec.ArchSpec.from_dict(d) @@ -518,6 +524,14 @@ def platform(): @memoized +def default_arch(): + """Default ``Arch`` object for this machine. + + See ``sys_type()``. + """ + return Arch(platform(), 'default_os', 'default_target') + + def sys_type(): """Print out the "default" platform-os-target tuple for this machine. @@ -530,8 +544,7 @@ def sys_type(): architectures. """ - arch = Arch(platform(), 'default_os', 'default_target') - return str(arch) + return str(default_arch()) @memoized |