Some cleaning up. Finally got arch_from_dict working successfully.
This commit is contained in:
parent
9ac2556285
commit
550df4cdd6
1 changed files with 15 additions and 66 deletions
|
@ -67,27 +67,6 @@ def __init__(self, name, compiler_strategy, module_name=None):
|
||||||
def set_platform(self, platform):
|
def set_platform(self, platform):
|
||||||
self.platform_name = platform.name
|
self.platform_name = platform.name
|
||||||
|
|
||||||
#def to_dict(self):
|
|
||||||
# d = {}
|
|
||||||
# d['name'] = self.name
|
|
||||||
# d['compiler_strategy'] = self.compiler_strategy
|
|
||||||
# d['module_name'] = self.module_name
|
|
||||||
# if self.platform_name:
|
|
||||||
# d['platform'] = self.platform_name
|
|
||||||
# return d
|
|
||||||
|
|
||||||
#@staticmethod
|
|
||||||
#def from_dict(d):
|
|
||||||
# if d is None:
|
|
||||||
# return None
|
|
||||||
# target = Target.__new__(Target)
|
|
||||||
# target.name = d['name']
|
|
||||||
# target.compiler_strategy = d['compiler_strategy']
|
|
||||||
# target.module_name = d['module_name']
|
|
||||||
# if 'platform' in d:
|
|
||||||
# target.platform_name = d['platform']
|
|
||||||
# return target
|
|
||||||
|
|
||||||
def _cmp_key(self):
|
def _cmp_key(self):
|
||||||
return (self.name, self.module_name)
|
return (self.name, self.module_name)
|
||||||
|
|
||||||
|
@ -147,24 +126,6 @@ def target(self, name):
|
||||||
name = self.back_end
|
name = self.back_end
|
||||||
|
|
||||||
return self.targets[name]
|
return self.targets[name]
|
||||||
|
|
||||||
#def _detect_linux_os(self):
|
|
||||||
# return OperatingSystem(py_platform.dist()[0], py_platform.dist()[1])
|
|
||||||
|
|
||||||
#def _detect_mac_os(self):
|
|
||||||
# mac_releases = {'10.6': "snowleopard",
|
|
||||||
# "10.7": "lion",
|
|
||||||
# "10.8": "mountainlion",
|
|
||||||
# "10.9": "mavericks",
|
|
||||||
# "10.10": "yosemite",
|
|
||||||
# "10.11": "elcapitan"}
|
|
||||||
# mac_ver = py_platform.mac_ver()[:-2]
|
|
||||||
# try:
|
|
||||||
# os_name = mac_releases[mac_ver]
|
|
||||||
# return OperatingSystem(os_name, mac_ver)
|
|
||||||
# except KeyError:
|
|
||||||
# os_name = "mac_os"
|
|
||||||
# return OperatingSystem(os_name, mac_ver)
|
|
||||||
|
|
||||||
def add_operating_system(self, name, os_class):
|
def add_operating_system(self, name, os_class):
|
||||||
""" Add the operating_system class object into the
|
""" Add the operating_system class object into the
|
||||||
|
@ -242,7 +203,8 @@ class Arch(namedtuple("Arch", "platform platform_os target")):
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return (self.platform.name +"-"+ self.platform_os.name + "-" + self.target.name)
|
return (self.platform.name +"-"+
|
||||||
|
self.platform_os.name + "-" + self.target.name)
|
||||||
|
|
||||||
def _cmp_key(self):
|
def _cmp_key(self):
|
||||||
return (self.platform.name, self.platform_os.name, self.target.name)
|
return (self.platform.name, self.platform_os.name, self.target.name)
|
||||||
|
@ -284,52 +246,39 @@ def _platform_from_dict(platform):
|
||||||
return platform_names[platform['name']]()
|
return platform_names[platform['name']]()
|
||||||
|
|
||||||
|
|
||||||
def _target_from_dict(target):
|
def _target_from_dict(target_dict):
|
||||||
target = Target.__new__(Target)
|
target = Target.__new__(Target)
|
||||||
target.name = d['name']
|
target.name = target_dict['name']
|
||||||
target.compiler_strategy = d['compiler_strategy']
|
#target.compiler_strategy = target_dict['compiler_strategy']
|
||||||
target.module_name = d['module_name']
|
target.module_name = target_dict['module_name']
|
||||||
if 'platform' in d:
|
if 'platform_name' in target_dict:
|
||||||
target.platform_name = d['platform']
|
target.platform_name = target_dict['platform_name']
|
||||||
return target
|
return target
|
||||||
|
|
||||||
def _operating_system_from_dict(os_dict):
|
def _operating_system_from_dict(os_dict, platform_class):
|
||||||
#TODO: Have a way to recognize the OS subclasses
|
|
||||||
name = os_dict['name']
|
name = os_dict['name']
|
||||||
os_list = all_platforms(True)
|
return platform_class.operating_system(name)
|
||||||
os_classes = {o.__name__:o for o in os_list}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def arch_from_dict(d):
|
def arch_from_dict(d):
|
||||||
if d is None:
|
if d is None:
|
||||||
return None
|
return None
|
||||||
arch = Arch
|
|
||||||
platform_dict = d['platform']
|
platform_dict = d['platform']
|
||||||
platform_os_dict = d['platform_os']
|
platform_os_dict = d['platform_os']
|
||||||
target_dict = d['target']
|
target_dict = d['target']
|
||||||
|
|
||||||
platform = _platform_from_dict(platform_dict)
|
platform = _platform_from_dict(platform_dict)
|
||||||
platform_os = _operating_system_from_dict(platform_os_dict)
|
platform_os = _operating_system_from_dict(platform_os_dict, platform)
|
||||||
target = _target_from_dict(target_dict)
|
target = _target_from_dict(target_dict)
|
||||||
|
|
||||||
arch.platform = platform
|
return Arch(platform, platform_os, target)
|
||||||
arch.platform_os = platform_os
|
|
||||||
arch.target = target
|
|
||||||
|
|
||||||
return arch
|
|
||||||
|
|
||||||
#TODO: Haven't changed name here but all_platforms should now pull os class list
|
|
||||||
@memoized
|
@memoized
|
||||||
def all_platforms(operating_system=False):
|
def all_platforms():
|
||||||
modules = []
|
modules = []
|
||||||
|
|
||||||
if operating_system:
|
mod_path = spack.platform_path
|
||||||
mod_path = spack.operating_system_path
|
mod_string = "spack.platformss"
|
||||||
mod_string = "spack.operating_systems"
|
|
||||||
else:
|
|
||||||
mod_path = spack.platform_path
|
|
||||||
mod_string = "spack.platformss"
|
|
||||||
|
|
||||||
for name in list_modules(mod_path):
|
for name in list_modules(mod_path):
|
||||||
mod_name = mod_string + name
|
mod_name = mod_string + name
|
||||||
|
|
Loading…
Reference in a new issue