summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-03-18 12:13:48 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-03-18 12:13:48 -0700
commit741bea032c2d6e1dc8a4227c588743fb58008a1c (patch)
tree8786dbda1cc628225965efb2d7c2afc824e9fd4b /lib
parent4e9ba4927224602216c8146aeb88cdc0d4342f98 (diff)
parent151b04637ef01b8cde5967df6165bd245311b90a (diff)
downloadspack-741bea032c2d6e1dc8a4227c588743fb58008a1c.tar.gz
spack-741bea032c2d6e1dc8a4227c588743fb58008a1c.tar.bz2
spack-741bea032c2d6e1dc8a4227c588743fb58008a1c.tar.xz
spack-741bea032c2d6e1dc8a4227c588743fb58008a1c.zip
Merge pull request #574 from LLNL/features/flattener
Created flatten_dependencies function
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/__init__.py3
-rw-r--r--lib/spack/spack/package.py29
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index 3051d3f742..0ba42bbbfc 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -188,3 +188,6 @@ __all__ += spack.directives.__all__
import spack.util.executable
from spack.util.executable import *
__all__ += spack.util.executable.__all__
+
+from spack.package import install_dependency_symlinks, flatten_dependencies, DependencyConflictError
+__all__ += ['install_dependency_symlinks', 'flatten_dependencies', 'DependencyConflictError']
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 291056a7b9..b488e4c49d 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1243,6 +1243,27 @@ class Package(object):
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):
"""Determine whether spack can handle a particular URL or not."""
url = urlparse(url_string)
@@ -1380,3 +1401,11 @@ class ExtensionConflictError(ExtensionError):
class ActivationError(ExtensionError):
def __init__(self, msg, long_msg=None):
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))