diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py index 64416e8b4c..b1da8ae4a2 100644 --- a/lib/spack/spack/architecture.py +++ b/lib/spack/spack/architecture.py @@ -61,18 +61,20 @@ def __init__(self,name, module_name=None): def set_architecture(self, architecture): # Target should get the architecture class. self.architecture = architecture - + @property def compiler_strategy(self): - if default_strategy: - return default_strategy - elif self.module_name: # If there is a module_name given then use MODULES + if self.module_name: # If there is a module_name given then use MODULES return "MODULES" else: return "PATH" + def __str__(self): + return self.name + + class Architecture(object): - """ Abstract class that each type of Architecture will subclass. Will return a instance of it once it + """ Abstract class that each type of Architecture will subclass. Will return a instance of it once it is returned """ @@ -110,12 +112,15 @@ def target(self, name): @classmethod def detect(self): - """ Subclass is responsible for implementing this method. + """ Subclass is responsible for implementing this method. Returns True if the architecture detects if it is the current architecture and False if it's not. """ raise NotImplementedError() - + + def __repr__(self): + return self.__str__ + def __str__(self): return self.name @@ -123,7 +128,7 @@ def __str__(self): def get_sys_type_from_spack_globals(): """Return the SYS_TYPE from spack globals, or None if it isn't set.""" if not hasattr(spack, "sys_type"): - return None + return None elif hasattr(spack.sys_type, "__call__"): return spack.sys_type() #If in __init__.py there is a sys_type() then call that else: @@ -147,7 +152,7 @@ def get_mac_sys_type(): def get_sys_type_from_uname(): - """ Returns a sys_type from the uname argument + """ Returns a sys_type from the uname argument Front-end config """ try: @@ -158,8 +163,8 @@ def get_sys_type_from_uname(): return None def get_sys_type_from_config_file(): - - spack_home_dir = os.environ["HOME"] + "/.spack" + + spack_home_dir = os.environ["HOME"] + "/.spack" yaml_file = os.path.join(spack_home_dir, 'architecture.yaml') try: config_dict = yaml.load(open(yaml_file)) # Fix this to have yaml.load() @@ -167,7 +172,7 @@ def get_sys_type_from_config_file(): front = arch['front'] back = arch['back'] return Architecture(front,back) - + except: print "No architecture.yaml config file found" return None @@ -182,7 +187,7 @@ def all_architectures(): mod = imp.load_source(mod_name, path) class_name = mod_to_class(name) if not hasattr(mod, class_name): - tty.die('No class %s defined in %s' % (class_name, mod_name)) + tty.die('No class %s defined in %s' % (class_name, mod_name)) cls = getattr(mod, class_name) if not inspect.isclass(cls): tty.die('%s.%s is not a class' % (mod_name, class_name)) @@ -197,15 +202,15 @@ def sys_type(): 1. YAML file that the user specifies the name of the architecture. e.g Cray-XC40 or Cray-XC30 2. UNAME 3. GLOBALS - 4. MAC OSX + 4. MAC OSX Yaml should be a priority here because we want the user to be able to specify the type of architecture to use. - If there is no yaml present then it should move on to the next function and stop immediately once it gets a + If there is no yaml present then it should move on to the next function and stop immediately once it gets a arch name """ # Try to create an architecture object using the config file FIRST - architecture_list = all_architectures() - architecture_list.sort(key = lambda a: a.priority) - + architecture_list = all_architectures() + architecture_list.sort(key = lambda a: a.priority) + for arch in architecture_list: if arch.detect(): return arch() diff --git a/lib/spack/spack/architectures/linux.py b/lib/spack/spack/architectures/linux.py index 7238575660..d7d9a994fa 100644 --- a/lib/spack/spack/architectures/linux.py +++ b/lib/spack/spack/architectures/linux.py @@ -1,14 +1,15 @@ -import subprocess -from spack.architecture import Architecture +import subprocess +from spack.architecture import Architecture, Target class Linux(Architecture): - priority = 60 - front_end = "x86_64" - back_end = "x86_64" - default = "x86_64" + priority = 60 + front_end = 'linux' + back_end = 'linux' + default = 'linux' def __init__(self): super(Linux, self).__init__('linux') + self.add_target('linux', Target('linux')) @classmethod def detect(self): diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index 191e858735..9e3be433fb 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -88,13 +88,13 @@ def __call__(self, *args, **kwargs): def load_module(mod): """Takes a module name and removes modules until it is possible to - load that module. It then loads the provided module. Depends on the + load that module. It then loads the provided module. Depends on the modulecmd implementation of modules used in cray and lmod. """ #Create an executable of the module command that will output python code modulecmd = which('modulecmd') modulecmd.add_default_arg('python') - + # Read the module and remove any conflicting modules # We do this without checking that they are already installed # for ease of programming because unloading a module that is not @@ -102,7 +102,7 @@ def load_module(mod): text = modulecmd('show', mod, return_oe=True).split() for i, word in enumerate(text): if word == 'conflict': - exec(compile(modulecmd('unload', text[i+1], return_oe=True), '', 'exec')) + exec(compile(modulecmd('unload', text[i+1], return_oe=True), '', 'exec')) # Load the module now that there are no conflicts load = modulecmd('load', mod, return_oe=True) exec(compile(load, '', 'exec')) diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 4be573fb12..41ff89a151 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -307,8 +307,12 @@ def __repr__(self): def __str__(self): """Return a string represntation of the compiler toolchain.""" - return "%s(%s)" % ( - self.name, '\n '.join((str(s) for s in (self.cc, self.cxx, self.f77, self.fc)))) + if self.modules: + return "%s(%s)" % ( + self.name, '\n '.join((str(s) for s in (self.cc, self.cxx, self.f77, self.fc, self.modules)))) + else: + return "%s(%s)" % ( + self.name, '\n '.join((str(s) for s in (self.cc, self.cxx, self.f77, self.fc)))) class CompilerAccessError(spack.error.SpackError): diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py index 6fc54daa61..23ff6cced4 100644 --- a/lib/spack/spack/compilers/__init__.py +++ b/lib/spack/spack/compilers/__init__.py @@ -44,15 +44,15 @@ _imported_compilers_module = 'spack.compilers' _required_instance_vars = ['cc', 'cxx', 'f77', 'fc'] -_optional_instance_vars = ['module'] +_optional_instance_vars = ['modules'] _default_order = ['gcc', 'intel', 'pgi', 'clang', 'xlc'] def _auto_compiler_spec(function): - def converter(cspec_like): + def converter(cspec_like, *args): if not isinstance(cspec_like, spack.spec.CompilerSpec): cspec_like = spack.spec.CompilerSpec(cspec_like) - return function(cspec_like) + return function(cspec_like, *args) return converter diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py index c5041d67be..4b4cb69033 100644 --- a/lib/spack/spack/concretize.py +++ b/lib/spack/spack/concretize.py @@ -97,32 +97,6 @@ def concretize_version(self, spec): def concretize_architecture(self, spec): - """If the spec already had an architecture, return. Otherwise if - the root of the DAG has an architecture, then use that. - Otherwise take the system's default architecture. - - Intuition: Architectures won't be set a lot, and generally you - want the host system's architecture. When architectures are - mised in a spec, it is likely because the tool requries a - cross-compiled component, e.g. for tools that run on BlueGene - or Cray machines. These constraints will likely come directly - from packages, so require the user to be explicit if they want - to mess with the architecture, and revert to the default when - they're not explicit. - """ - if spec.architecture is not None: - return False - - if spec.root.architecture: - spec.architecture = spec.root.architecture - else: - spec.architecture = spack.architecture.sys_type() - - assert(spec.architecture is not None) - return True # changed - - - def new_concretize_architecture(self, spec): """If the spec already has an architecture and it is a an architecture type, return. Otherwise, if it has an architecture that is a string type, generate an architecture based on that type. If it has no architecture and the root of the @@ -146,7 +120,7 @@ def new_concretize_architecture(self, spec): else: arch = spack.architecture.sys_type() spec.architecture = arch.target('default') - + return True #changed diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index 3e91958c2c..bc655d6051 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -199,6 +199,7 @@ def get_config(category_name): category.result_dict = _merge_dicts(category.result_dict, result) else: category.result_dict = result + return category.result_dict @@ -208,7 +209,7 @@ def get_compilers_config(arch=None): configuration""" global _compiler_by_arch if not arch: - arch = spack.architecture.sys_type() + arch = str(spack.architecture.sys_type()) if arch in _compiler_by_arch: return _compiler_by_arch[arch] @@ -305,7 +306,7 @@ def add_to_compiler_config(addition_dict, scope=None, arch=None): """Add compilerss to the configuration files""" if not arch: arch = spack.architecture.sys_type() - add_to_config('compilers', { arch : addition_dict }, scope) + add_to_config('compilers', { str(arch) : addition_dict }, scope) clear_config_caches()