summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/__init__.py3
-rw-r--r--lib/spack/spack/directory_layout.py24
-rw-r--r--lib/spack/spack/package.py30
3 files changed, 33 insertions, 24 deletions
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index ab78ecef30..155e190597 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -174,3 +174,6 @@ __all__ += spack.directives.__all__
import spack.util.executable
from spack.util.executable import *
__all__ += spack.util.executable.__all__
+
+from spack.package import flat_install, flatten_dependencies, DependencyConflictError
+__all__ += ['flat_install', 'flatten_dependencies', 'DependencyConflictError']
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py
index dfd0dc42e4..e275031387 100644
--- a/lib/spack/spack/directory_layout.py
+++ b/lib/spack/spack/directory_layout.py
@@ -132,23 +132,6 @@ class DirectoryLayout(object):
raise NotImplementedError()
- def flatten_dependencies(self, 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 = self.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 path_for_spec(self, spec):
"""Return an absolute path from the root to a directory for the spec."""
_check_concrete(spec)
@@ -498,10 +481,3 @@ class NoSuchExtensionError(DirectoryLayoutError):
super(NoSuchExtensionError, self).__init__(
"%s cannot be removed from %s because it's not activated."% (
ext_spec.short_spec, spec.short_spec))
-
-class DependencyConflictError(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))
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 972a0410b9..1a962268cf 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1211,6 +1211,28 @@ class Package(object):
return " ".join("-Wl,-rpath,%s" % p for p in self.rpath)
+def flat_install(pkg, spec, prefix):
+ """Execute a dummy install and flatten dependencies"""
+ os.mkdir(prefix+'/libs')
+ flatten_dependencies(spec, prefix+'/libs')
+
+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)
@@ -1348,3 +1370,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))