summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMario Melara <maamelara@gmail.com>2016-06-03 15:59:00 -0700
committerMario Melara <maamelara@gmail.com>2016-06-03 15:59:00 -0700
commitbc557cc76503cd7694051ddf5a2529a646810b90 (patch)
treec8e394bbcf391bc76861a844db635540bafa38ac /lib
parent24d160e93ed80052ad30f99ce36b34de2872a888 (diff)
parent7bdf63a0fa87cce6f9237ffae4a8903311327d54 (diff)
downloadspack-bc557cc76503cd7694051ddf5a2529a646810b90.tar.gz
spack-bc557cc76503cd7694051ddf5a2529a646810b90.tar.bz2
spack-bc557cc76503cd7694051ddf5a2529a646810b90.tar.xz
spack-bc557cc76503cd7694051ddf5a2529a646810b90.zip
Merge branch 'features/newarch' of https://github.com/NERSC/spack into features/newarch
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/architecture.py14
-rw-r--r--lib/spack/spack/database.py10
-rw-r--r--lib/spack/spack/operating_systems/linux_distro.py13
-rw-r--r--lib/spack/spack/spec.py5
4 files changed, 26 insertions, 16 deletions
diff --git a/lib/spack/spack/architecture.py b/lib/spack/spack/architecture.py
index ee0d2173c7..e74e72d6cd 100644
--- a/lib/spack/spack/architecture.py
+++ b/lib/spack/spack/architecture.py
@@ -480,25 +480,23 @@ def arch_from_dict(d):
@memoized
def all_platforms():
- modules = []
-
+ classes = []
mod_path = spack.platform_path
- mod_string = "spack.platformss"
+ parent_module = "spack.platforms"
for name in list_modules(mod_path):
- mod_name = mod_string + name
- path = join_path(mod_path, name) + ".py"
- mod = imp.load_source(mod_name, path)
+ mod_name = '%s.%s' % (parent_module, name)
class_name = mod_to_class(name)
+ mod = __import__(mod_name, fromlist=[class_name])
if not hasattr(mod, class_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))
- modules.append(cls)
+ classes.append(cls)
- return modules
+ return classes
@memoized
diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py
index e768ddf5fe..38bb7541e0 100644
--- a/lib/spack/spack/database.py
+++ b/lib/spack/spack/database.py
@@ -214,9 +214,10 @@ class Database(object):
# Add dependencies from other records in the install DB to
# form a full spec.
- for dep_hash in spec_dict[spec.name]['dependencies'].values():
- child = self._read_spec_from_yaml(dep_hash, installs, hash_key)
- spec._add_dependency(child)
+ if 'dependencies' in spec_dict[spec.name]:
+ for dep_hash in spec_dict[spec.name]['dependencies'].values():
+ child = self._read_spec_from_yaml(dep_hash, installs, hash_key)
+ spec._add_dependency(child)
# Specs from the database need to be marked concrete because
# they represent actual installations.
@@ -289,7 +290,8 @@ class Database(object):
except Exception as e:
tty.warn("Invalid database reecord:",
"file: %s" % self._index_path,
- "hash: %s" % hash_key, "cause: %s" % str(e))
+ "hash: %s" % hash_key,
+ "cause: %s: %s" % (type(e).__name__, str(e)))
raise
self._data = data
diff --git a/lib/spack/spack/operating_systems/linux_distro.py b/lib/spack/spack/operating_systems/linux_distro.py
index d0f24d842f..2e3c72719b 100644
--- a/lib/spack/spack/operating_systems/linux_distro.py
+++ b/lib/spack/spack/operating_systems/linux_distro.py
@@ -1,3 +1,4 @@
+import re
import platform as py_platform
from spack.architecture import OperatingSystem
@@ -9,7 +10,13 @@ class LinuxDistro(OperatingSystem):
platform.dist()
"""
def __init__(self):
- name = py_platform.dist()[0]
- version = py_platform.dist()[1].split(".")[0] # Grabs major version from tuple
+ distname, version, _ = py_platform.linux_distribution(
+ full_distribution_name=False)
- super(LinuxDistro, self).__init__(name, version)
+ # Grabs major version from tuple on redhat; on other platforms
+ # grab the first legal identifier in the version field. On
+ # debian you get things like 'wheezy/sid'; sid means unstable.
+ # We just record 'wheezy' and don't get quite so detailed.
+ version = re.split(r'[^\w-]', version)[0]
+
+ super(LinuxDistro, self).__init__(distname, version)
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index f8bad3ff03..89c03a13b7 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -2150,10 +2150,13 @@ class SpecLexer(spack.parse.Lexer):
(r'\s+', lambda scanner, val: None)])
+# Lexer is always the same for every parser.
+_lexer = SpecLexer()
+
class SpecParser(spack.parse.Parser):
def __init__(self):
- super(SpecParser, self).__init__(SpecLexer())
+ super(SpecParser, self).__init__(_lexer)
self.previous = None
def do_parse(self):