summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-05-05 00:47:54 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2014-06-22 12:33:49 -0700
commit8d78e1142f66ad7e7a8c0735925c154bcc41c22b (patch)
treeb3aa050957a60ad7d2dd5c2f10acb4665bcdfb04
parent1fa20ec2ba404912bd69c628f75f7ae4387d2fad (diff)
downloadspack-8d78e1142f66ad7e7a8c0735925c154bcc41c22b.tar.gz
spack-8d78e1142f66ad7e7a8c0735925c154bcc41c22b.tar.bz2
spack-8d78e1142f66ad7e7a8c0735925c154bcc41c22b.tar.xz
spack-8d78e1142f66ad7e7a8c0735925c154bcc41c22b.zip
Make Compiler constructor behave like Spec constructor.
-rw-r--r--lib/spack/spack/cmd/compilers.py13
-rw-r--r--lib/spack/spack/cmd/find.py17
-rw-r--r--lib/spack/spack/compiler.py6
-rw-r--r--lib/spack/spack/compilers/__init__.py7
-rw-r--r--lib/spack/spack/globals.py7
-rw-r--r--lib/spack/spack/spec.py24
6 files changed, 47 insertions, 27 deletions
diff --git a/lib/spack/spack/cmd/compilers.py b/lib/spack/spack/cmd/compilers.py
index c3f204e3d3..f2bf2ed0b1 100644
--- a/lib/spack/spack/cmd/compilers.py
+++ b/lib/spack/spack/cmd/compilers.py
@@ -24,11 +24,20 @@
##############################################################################
import llnl.util.tty as tty
from llnl.util.tty.colify import colify
+from llnl.util.lang import index_by
import spack.compilers
+import spack.spec
description = "List available compilers"
+
def compilers(parser, args):
- tty.msg("Supported compilers")
- colify(spack.compilers.supported_compilers(), indent=4)
+ tty.msg("Available compilers")
+
+ # Index compilers
+ index = index_by(spack.compilers.supported_compilers(), 'name')
+
+ for name, compilers in index.items():
+ tty.hline(name, char='=', color=spack.spec.compiler_color)
+ colify(compilers, indent=4)
diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py
index b6ec123c92..eaa3632043 100644
--- a/lib/spack/spack/cmd/find.py
+++ b/lib/spack/spack/cmd/find.py
@@ -29,7 +29,7 @@ from StringIO import StringIO
import llnl.util.tty as tty
from llnl.util.tty.colify import colify
from llnl.util.tty.color import *
-from llnl.util.lang import partition_list
+from llnl.util.lang import partition_list, index_by
import spack
import spack.spec
@@ -49,9 +49,6 @@ def setup_parser(subparser):
def find(parser, args):
- def hasher():
- return collections.defaultdict(hasher)
-
# Filter out specs that don't exist.
query_specs = spack.cmd.parse_specs(args.query_specs)
query_specs, nonexisting = partition_list(
@@ -64,15 +61,9 @@ def find(parser, args):
return
# Make a dict with specs keyed by architecture and compiler.
- index = hasher()
- for spec in spack.db.installed_package_specs():
- # Check whether this installed package matches any query.
- if query_specs and not any(spec.satisfies(q) for q in query_specs):
- continue
-
- if spec.compiler not in index[spec.architecture]:
- index[spec.architecture][spec.compiler] = []
- index[spec.architecture][spec.compiler].append(spec)
+ specs = [s for s in spack.db.installed_package_specs()
+ if not query_specs or any(spec.satisfies(q) for q in query_specs)]
+ index = index_by(specs, 'architecture', 'compiler')
# Traverse the index and print out each package
for architecture in index:
diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py
index f2df6a696d..38b7780264 100644
--- a/lib/spack/spack/compiler.py
+++ b/lib/spack/spack/compiler.py
@@ -7,7 +7,7 @@ from spack.util import Executable
from subprocess import check_output
-def _verify_compiler(*paths):
+def _verify_executables(*paths):
for path in paths:
if not os.path.isfile(path) and os.access(path, os.X_OK):
raise InvalidCompilerPathError(path)
@@ -37,13 +37,13 @@ class Compiler(object):
def __init__(self, cc, cxx, f77, f90):
- _verify_compiler(cc, cxx, f77, f90)
+ _verify_executables(cc, cxx, f77, f90)
+
self.cc = Executable(cc)
self.cxx = Executable(cxx)
self.f77 = Executable(f77)
self.f90 = Executable(f90)
-
@property
@memoized
def version(self):
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index 5448e709c4..c6398f736d 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -26,16 +26,19 @@
# This needs to be expanded for full compiler support.
#
from llnl.util.lang import memoized, list_modules
+
import spack
import spack.compilers.gcc
+import spack.spec
@memoized
def supported_compilers():
- return [c for c in list_modules(spack.compilers_path)]
+ return [spack.spec.Compiler(c) for c in list_modules(spack.compilers_path)]
def supported(compiler):
- return compiler in supported_compilers()
+ return True
+# return compiler in supported_compilers()
@memoized
diff --git a/lib/spack/spack/globals.py b/lib/spack/spack/globals.py
index 9fc40845b0..6c3c5c9645 100644
--- a/lib/spack/spack/globals.py
+++ b/lib/spack/spack/globals.py
@@ -43,15 +43,18 @@ spack_file = join_path(prefix, "bin", "spack")
lib_path = join_path(prefix, "lib", "spack")
build_env_path = join_path(lib_path, "env")
module_path = join_path(lib_path, "spack")
-compilers_path = join_path(module_path, "compilers")
test_path = join_path(module_path, "test")
-
var_path = join_path(prefix, "var", "spack")
stage_path = join_path(var_path, "stage")
install_path = join_path(prefix, "opt")
#
+# Place to look for usable compiler installations
+#
+compilers_path = join_path(var_path, "compilers")
+
+#
# Set up the packages database.
#
packages_path = join_path(var_path, "packages")
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 6416ff9487..900e36a8fb 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -173,11 +173,16 @@ class Compiler(object):
"""The Compiler field represents the compiler or range of compiler
versions that a package should be built with. Compilers have a
name and a version list. """
- def __init__(self, name, version=None):
+ def __init__(self, compiler_spec_like):
+ c = SpecParser().parse_compiler(compiler_spec_like)
+ self.name = c.name
+ self.versions = c.versions
+
+
+ def __init__(self, name, version):
self.name = name
self.versions = VersionList()
- if version:
- self.versions.add(version)
+ self.versions.add(version)
def _add_version(self, version):
@@ -210,7 +215,8 @@ class Compiler(object):
def copy(self):
- clone = Compiler(self.name)
+ clone = Compiler.__new__(Compiler)
+ clone.name = self.name
clone.versions = self.versions.copy()
return clone
@@ -1188,6 +1194,11 @@ class SpecParser(spack.parse.Parser):
return specs
+ def parse_compiler(self, text):
+ self.setup(text)
+ return self.compiler()
+
+
def spec(self):
"""Parse a spec out of the input. If a spec is supplied, then initialize
and return it instead of creating a new one."""
@@ -1279,7 +1290,10 @@ class SpecParser(spack.parse.Parser):
def compiler(self):
self.expect(ID)
self.check_identifier()
- compiler = Compiler(self.token.value)
+
+ compiler = Compiler.__new__(Compiler)
+ compiler.name = self.token.value
+ compiler.versions = VersionList()
if self.accept(AT):
vlist = self.version_list()
for version in vlist: