summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/build_environment.py4
-rw-r--r--lib/spack/spack/cmd/create.py2
-rw-r--r--lib/spack/spack/cmd/md5.py33
-rw-r--r--lib/spack/spack/compilers/__init__.py32
-rw-r--r--lib/spack/spack/modules.py13
-rw-r--r--lib/spack/spack/repository.py12
6 files changed, 68 insertions, 28 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index b2db83acb7..1b87778080 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -237,9 +237,9 @@ def set_module_variables_for_package(pkg, m):
def get_rpaths(pkg):
"""Get a list of all the rpaths for a package."""
rpaths = [pkg.prefix.lib, pkg.prefix.lib64]
- rpaths.extend(d.prefix.lib for d in pkg.spec.traverse(root=False)
+ rpaths.extend(d.prefix.lib for d in pkg.spec.dependencies.values()
if os.path.isdir(d.prefix.lib))
- rpaths.extend(d.prefix.lib64 for d in pkg.spec.traverse(root=False)
+ rpaths.extend(d.prefix.lib64 for d in pkg.spec.dependencies.values()
if os.path.isdir(d.prefix.lib64))
return rpaths
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index edcea0718c..6809209046 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -222,7 +222,7 @@ def fetch_tarballs(url, name, args):
archives_to_fetch = 1
if not versions:
# If the fetch failed for some reason, revert to what the user provided
- versions = { version : url }
+ versions = { "version" : url }
elif len(versions) > 1:
tty.msg("Found %s versions of %s:" % (len(versions), name),
*spack.cmd.elide_list(
diff --git a/lib/spack/spack/cmd/md5.py b/lib/spack/spack/cmd/md5.py
index ef1e4f3475..879ef9f7b7 100644
--- a/lib/spack/spack/cmd/md5.py
+++ b/lib/spack/spack/cmd/md5.py
@@ -23,15 +23,31 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import os
-import hashlib
import argparse
+import hashlib
+
+from contextlib import contextmanager
import llnl.util.tty as tty
from llnl.util.filesystem import *
import spack.util.crypto
+from spack.stage import Stage, FailedDownloadError
+
+description = "Calculate md5 checksums for files/urls."
-description = "Calculate md5 checksums for files."
+@contextmanager
+def stager(url):
+ _cwd = os.getcwd()
+ _stager = Stage(url)
+ try:
+ _stager.fetch()
+ yield _stager
+ except FailedDownloadError:
+ tty.msg("Failed to fetch %s" % url)
+ finally:
+ _stager.destroy()
+ os.chdir(_cwd) # the Stage class changes the current working dir so it has to be restored
def setup_parser(subparser):
setup_parser.parser = subparser
@@ -45,9 +61,12 @@ def md5(parser, args):
for f in args.files:
if not os.path.isfile(f):
- tty.die("Not a file: %s" % f)
- if not can_access(f):
- tty.die("Cannot read file: %s" % f)
+ with stager(f) as stage:
+ checksum = spack.util.crypto.checksum(hashlib.md5, stage.archive_file)
+ print "%s %s" % (checksum, f)
+ else:
+ if not can_access(f):
+ tty.die("Cannot read file: %s" % f)
- checksum = spack.util.crypto.checksum(hashlib.md5, f)
- print "%s %s" % (checksum, f)
+ checksum = spack.util.crypto.checksum(hashlib.md5, f)
+ print "%s %s" % (checksum, f)
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index 6159ef576c..3a04bc2ebc 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -74,28 +74,36 @@ def _to_dict(compiler):
def get_compiler_config(arch=None, scope=None):
"""Return the compiler configuration for the specified architecture.
"""
- # If any configuration file has compilers, just stick with the
- # ones already configured.
- config = spack.config.get_config('compilers', scope=scope)
-
+ # Check whether we're on a front-end (native) architecture.
my_arch = spack.architecture.sys_type()
if arch is None:
arch = my_arch
- if arch in config:
- return config[arch]
-
- # Only for the current arch in *highest* scope: automatically try to
- # find compilers if none are configured yet.
- if arch == my_arch and scope == 'user':
+ def init_compiler_config():
+ """Compiler search used when Spack has no compilers."""
config[arch] = {}
compilers = find_compilers(*get_path('PATH'))
for compiler in compilers:
config[arch].update(_to_dict(compiler))
spack.config.update_config('compilers', config, scope=scope)
- return config[arch]
- return {}
+ config = spack.config.get_config('compilers', scope=scope)
+
+ # Update the configuration if there are currently no compilers
+ # configured. Avoid updating automatically if there ARE site
+ # compilers configured but no user ones.
+ if arch == my_arch and arch not in config:
+ if scope is None:
+ # We know no compilers were configured in any scope.
+ init_compiler_config()
+ elif scope == 'user':
+ # Check the site config and update the user config if
+ # nothing is configured at the site level.
+ site_config = spack.config.get_config('compilers', scope='site')
+ if not site_config:
+ init_compiler_config()
+
+ return config[arch] if arch in config else {}
def add_compilers_to_config(compilers, arch=None, scope=None):
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index 7036626e29..c834763564 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -194,12 +194,14 @@ class Dotkit(EnvModule):
@property
def file_name(self):
return join_path(Dotkit.path, self.spec.architecture,
- self.spec.format('$_$@$%@$+$#.dk'))
+ '%s.dk' % self.use_name)
@property
def use_name(self):
- return self.spec.format('$_$@$%@$+$#')
-
+ return "%s-%s-%s-%s-%s" % (self.spec.name, self.spec.version,
+ self.spec.compiler.name,
+ self.spec.compiler.version,
+ self.spec.dag_hash())
def _write(self, dk_file):
# Category
@@ -235,7 +237,10 @@ class TclModule(EnvModule):
@property
def use_name(self):
- return self.spec.format('$_$@$%@$+$#')
+ return "%s-%s-%s-%s-%s" % (self.spec.name, self.spec.version,
+ self.spec.compiler.name,
+ self.spec.compiler.version,
+ self.spec.dag_hash())
def _write(self, m_file):
diff --git a/lib/spack/spack/repository.py b/lib/spack/spack/repository.py
index 31596cee7a..f58cd52125 100644
--- a/lib/spack/spack/repository.py
+++ b/lib/spack/spack/repository.py
@@ -233,6 +233,11 @@ class RepoPath(object):
return providers
+ @_autospec
+ def extensions_for(self, extendee_spec):
+ return [p for p in self.all_packages() if p.extends(extendee_spec)]
+
+
def find_module(self, fullname, path=None):
"""Implements precedence for overlaid namespaces.
@@ -295,8 +300,11 @@ class RepoPath(object):
for repo in self.repos:
if spec.name in repo:
return repo
- else:
- raise UnknownPackageError(spec.name)
+
+ # If the package isn't in any repo, return the one with
+ # highest precedence. This is for commands like `spack edit`
+ # that can operate on packages that don't exist yet.
+ return self.first_repo()
@_autospec