summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMario Melara <maamelara@gmail.com>2015-10-20 13:33:21 -0700
committerMario Melara <maamelara@gmail.com>2015-10-20 13:33:21 -0700
commit3ba2842b53752e9a3ec8766f3a1350c6cc7577a2 (patch)
tree956423b41878539d41440c52c8bf40804540faf4 /lib
parentfec197ccac94af485745b6b40d8150b4ae030e99 (diff)
downloadspack-3ba2842b53752e9a3ec8766f3a1350c6cc7577a2.tar.gz
spack-3ba2842b53752e9a3ec8766f3a1350c6cc7577a2.tar.bz2
spack-3ba2842b53752e9a3ec8766f3a1350c6cc7577a2.tar.xz
spack-3ba2842b53752e9a3ec8766f3a1350c6cc7577a2.zip
Got Architecture class working the way i wanted to. Next to write tests
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/architecture.py70
1 files changed, 37 insertions, 33 deletions
diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py
index 8f74fbc2e1..1a9f9de2cb 100644
--- a/lib/spack/spack/architecture.py
+++ b/lib/spack/spack/architecture.py
@@ -34,47 +34,50 @@ from external import yaml
class InvalidSysTypeError(serr.SpackError):
def __init__(self, sys_type):
- super(InvalidSysTypeError, self).__init__(
- "Invalid sys_type value for Spack: " + sys_type)
+ super(InvalidSysTypeError, self).__init__("Invalid sys_type value for Spack: " + sys_type)
class NoSysTypeError(serr.SpackError):
def __init__(self):
- super(NoSysTypeError, self).__init__(
- "Could not determine sys_type for this machine.")
+ super(NoSysTypeError, self).__init__("Could not determine sys_type for this machine.")
+
class Architecture(object):
- def __init__(self, *arch_name):
+ """ Architecture class that contains a dictionary of architecture name and compiler search strategy methods.
+ The idea is to create an object that Spack can interact with and know how to search for the compiler
+ If it is on a Cray architecture it should look in modules. If it is anything else search $PATH.
+ """
+
+ def __init__(self, front=None, back=None):
- """ Constructor for the architecture class. Should return a dictionary of name (grabbed from uname) and a strategy for
- searching for that architecture's compiler. The target passed to it should be a dictionary of names and strategies.
+ """ Constructor for the architecture class. Should return a dictionary of name (grabbed from uname)
+ and a strategy for searching for that architecture's compiler.
+ The target passed to it should be a dictionary of names and strategies.
"""
- self.arch_dict = {}
- self.arch_name = arch_name
-
- def add_arch_strategy(self):
- """ Create a dictionary using the tuples of arch_names"""
- for n in self.arch_name:
- if 'cray' in n.lower():
- self.arch_dict[n] = "MODULES"
- elif 'linux' in n.lower() or 'x86_64' in n.lower():
- self.arch_dict[n] = "PATH"
- else:
- self.arch_dict[n] = ""
-
- def get_arch_dict(self):
- """ Grab the dictionary from the Architecture class, rather than access the internal Architecture attributes """
- return self.arch_dict
-
- def __eq__(self, other):
- if self.arch_dict != {} and other.arch_dict != {}:
- return self.arch_dict == other.arch_dict
- else:
- return self.arch_name == self.arch_name
-
+ names = []
+ names.append(front)
+ names.append(back)
+
+ def add_compiler_strategy(names):
+ """ Create a dictionary of {'arch-name': 'strategy'}
+ This will tell Spack whether to look in the $PATH
+ or $MODULES location for compilers
+ """
+ d = {}
+ for n in names:
+ if n:
+ if 'cray' in n.lower():
+ d[n] = "MODULES"
+ elif 'linux' in n.lower():
+ d[n] = "PATH"
+ else:
+ d[n] = 'No Strategy'
+ return d
+
+ self.arch_dict = add_compiler_strategy(names)
-def get_sys_type_from_spack_globals():
- """Return the SYS_TYPE from spack globals, or None if it isn't set. Front-end"""
+def get_sys_type_from_spack_globals(): #TODO: Figure out how this function works
+ """Return the SYS_TYPE from spack globals, or None if it isn't set."""
if not hasattr(spack, "sys_type"):
return None
elif hasattr(spack.sys_type, "__call__"):
@@ -104,7 +107,7 @@ def get_sys_type_from_uname():
""" Returns a sys_type from the uname argument
Front-end config
"""
- return Architecture(os.uname()[0] + " " + os.uname()[-1])
+ return Architecture(os.uname()[0])
def get_sys_type_from_config_file():
@@ -149,6 +152,7 @@ def sys_type(): # This function is going to give me issues isn't it??
for func in functions:
sys_type = None
sys_type = func()
+
if sys_type:
break