Merge branch 'develop' of https://github.com/LLNL/spack into features/env_objects_flying_around

Conflicts:
	lib/spack/spack/package.py
	var/spack/repos/builtin/packages/netlib-scalapack/package.py
This commit is contained in:
alalazo 2016-03-21 09:46:49 +01:00
commit fbeffee91e
9 changed files with 71 additions and 14 deletions

View file

@ -1844,6 +1844,20 @@ dedicated process.
.. _prefix-objects: .. _prefix-objects:
Failing the build
----------------------
Sometimes you don't want a package to successfully install unless some
condition is true. You can explicitly cause the build to fail from
``install()`` by raising an ``InstallError``, for example:
.. code-block:: python
if spec.architecture.startswith('darwin'):
raise InstallError('This package does not build on Mac OS X!')
Prefix objects Prefix objects
---------------------- ----------------------

View file

@ -188,3 +188,10 @@
import spack.util.executable import spack.util.executable
from spack.util.executable import * from spack.util.executable import *
__all__ += spack.util.executable.__all__ __all__ += spack.util.executable.__all__
from spack.package import \
install_dependency_symlinks, flatten_dependencies, DependencyConflictError, \
InstallError, ExternalPackageError
__all__ += [
'install_dependency_symlinks', 'flatten_dependencies', 'DependencyConflictError',
'InstallError', 'ExternalPackageError']

View file

@ -40,7 +40,8 @@ class Gcc(Compiler):
fc_names = ['gfortran'] fc_names = ['gfortran']
# MacPorts builds gcc versions with prefixes and -mp-X.Y suffixes. # MacPorts builds gcc versions with prefixes and -mp-X.Y suffixes.
suffixes = [r'-mp-\d\.\d'] # Homebrew and Linuxes may build gcc with -X, -X.Y suffixes
suffixes = [r'-mp-\d\.\d', r'-\d\.\d', r'-\d']
# Named wrapper links within spack.build_env_path # Named wrapper links within spack.build_env_path
link_paths = {'cc' : 'gcc/gcc', link_paths = {'cc' : 'gcc/gcc',

View file

@ -1261,6 +1261,28 @@ def rpath_args(self):
"""Get the rpath args as a string, with -Wl,-rpath, for each element.""" """Get the rpath args as a string, with -Wl,-rpath, for each element."""
return " ".join("-Wl,-rpath,%s" % p for p in self.rpath) return " ".join("-Wl,-rpath,%s" % p for p in self.rpath)
def install_dependency_symlinks(pkg, spec, prefix):
"""Execute a dummy install and flatten dependencies"""
flatten_dependencies(spec, prefix)
def flatten_dependencies(spec, flat_dir):
"""Make each dependency of spec present in dir via symlink."""
for dep in spec.traverse(root=False):
name = dep.name
dep_path = spack.install_layout.path_for_spec(dep)
dep_files = LinkTree(dep_path)
os.mkdir(flat_dir+'/'+name)
conflict = dep_files.find_conflict(flat_dir+'/'+name)
if conflict:
raise DependencyConflictError(conflict)
dep_files.merge(flat_dir+'/'+name)
def validate_package_url(url_string): def validate_package_url(url_string):
"""Determine whether spack can handle a particular URL or not.""" """Determine whether spack can handle a particular URL or not."""
url = urlparse(url_string) url = urlparse(url_string)
@ -1348,6 +1370,10 @@ def __init__(self, message, long_msg=None):
super(InstallError, self).__init__(message, long_msg) super(InstallError, self).__init__(message, long_msg)
class ExternalPackageError(InstallError):
"""Raised by install() when a package is only for external use."""
class PackageStillNeededError(InstallError): class PackageStillNeededError(InstallError):
"""Raised when package is still needed by another on uninstall.""" """Raised when package is still needed by another on uninstall."""
def __init__(self, spec, dependents): def __init__(self, spec, dependents):
@ -1398,3 +1424,11 @@ def __init__(self, path):
class ActivationError(ExtensionError): class ActivationError(ExtensionError):
def __init__(self, msg, long_msg=None): def __init__(self, msg, long_msg=None):
super(ActivationError, self).__init__(msg, long_msg) super(ActivationError, self).__init__(msg, long_msg)
class DependencyConflictError(spack.error.SpackError):
"""Raised when the dependencies cannot be flattened as asked for."""
def __init__(self, conflict):
super(DependencyConflictError, self).__init__(
"%s conflicts with another file in the flattened directory." %(
conflict))

View file

@ -142,7 +142,7 @@ def split_url_extension(path):
def downloaded_file_extension(path): def downloaded_file_extension(path):
"""This returns the type of archive a URL refers to. This is """This returns the type of archive a URL refers to. This is
sometimes confusing becasue of URLs like: sometimes confusing because of URLs like:
(1) https://github.com/petdance/ack/tarball/1.93_02 (1) https://github.com/petdance/ack/tarball/1.93_02

View file

@ -27,13 +27,12 @@
from itertools import product from itertools import product
from spack.util.executable import which from spack.util.executable import which
# Supported archvie extensions. # Supported archive extensions.
PRE_EXTS = ["tar"] PRE_EXTS = ["tar"]
EXTS = ["gz", "bz2", "xz", "Z", "zip", "tgz"] EXTS = ["gz", "bz2", "xz", "Z", "zip", "tgz"]
# Add EXTS last so that .tar.gz is matched *before* tar.gz # Add PRE_EXTS and EXTS last so that .tar.gz is matched *before* .tar or .gz
ALLOWED_ARCHIVE_TYPES = [".".join(l) for l in product(PRE_EXTS, EXTS)] + EXTS ALLOWED_ARCHIVE_TYPES = [".".join(l) for l in product(PRE_EXTS, EXTS)] + PRE_EXTS + EXTS
def allowed_archive(path): def allowed_archive(path):
return any(path.endswith(t) for t in ALLOWED_ARCHIVE_TYPES) return any(path.endswith(t) for t in ALLOWED_ARCHIVE_TYPES)

View file

@ -141,7 +141,7 @@ function _spack_pathadd {
fi fi
# Do the actual prepending here. # Do the actual prepending here.
eval "_pa_oldvalue=\$${_pa_varname}" eval "_pa_oldvalue=\${${_pa_varname}:-}"
if [ -d "$_pa_new_path" ] && [[ ":$_pa_oldvalue:" != *":$_pa_new_path:"* ]]; then if [ -d "$_pa_new_path" ] && [[ ":$_pa_oldvalue:" != *":$_pa_new_path:"* ]]; then
if [ -n "$_pa_oldvalue" ]; then if [ -n "$_pa_oldvalue" ]; then

View file

@ -41,8 +41,8 @@ def install(self, spec, prefix):
make("install") make("install")
def modify_module(self, module, spec, dependent_spec): def modify_module(self, module, spec, dependent_spec):
# TODO treat OS that are not Linux... lib_dsuffix = '.dylib' if sys.platform == 'darwin' else '.so'
lib_suffix = '.so' if '+shared' in spec['scalapack'] else '.a' lib_suffix = lib_dsuffix if '+shared' in spec['scalapack'] else '.a'
spec['scalapack'].fc_link = '-L%s -lscalapack' % spec['scalapack'].prefix.lib spec['scalapack'].fc_link = '-L%s -lscalapack' % spec['scalapack'].prefix.lib
spec['scalapack'].cc_link = spec['scalapack'].fc_link spec['scalapack'].cc_link = spec['scalapack'].fc_link

View file

@ -1,4 +1,5 @@
from spack import * from spack import *
import sys
class Openblas(Package): class Openblas(Package):
"""OpenBLAS: An optimized BLAS library""" """OpenBLAS: An optimized BLAS library"""
@ -16,13 +17,14 @@ def install(self, spec, prefix):
make('libs', 'netlib', 'shared', 'CC=cc', 'FC=f77') make('libs', 'netlib', 'shared', 'CC=cc', 'FC=f77')
make('install', "PREFIX='%s'" % prefix) make('install', "PREFIX='%s'" % prefix)
lib_dsuffix = 'dylib' if sys.platform == 'darwin' else 'so'
# Blas virtual package should provide blas.a and libblas.a # Blas virtual package should provide blas.a and libblas.a
with working_dir(prefix.lib): with working_dir(prefix.lib):
symlink('libopenblas.a', 'blas.a') symlink('libopenblas.a', 'blas.a')
symlink('libopenblas.a', 'libblas.a') symlink('libopenblas.a', 'libblas.a')
symlink('libopenblas.so', 'libblas.so') symlink('libopenblas.%s' % lib_dsuffix, 'libblas.%s' % lib_dsuffix)
# Lapack virtual package should provide liblapack.a # Lapack virtual package should provide liblapack.a
with working_dir(prefix.lib): with working_dir(prefix.lib):
symlink('libopenblas.a', 'liblapack.a') symlink('libopenblas.a', 'liblapack.a')
symlink('libopenblas.so', 'liblapack.so') symlink('libopenblas.%s' % lib_dsuffix, 'liblapack.%s' % lib_dsuffix)