Refactoring flat_install
This commit is contained in:
parent
80495e50f9
commit
76672a4e34
@ -174,3 +174,6 @@
|
||||
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']
|
||||
|
@ -132,23 +132,6 @@ def remove_extension(self, spec, ext_spec):
|
||||
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 @@ def __init__(self, spec, ext_spec):
|
||||
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))
|
||||
|
@ -1211,6 +1211,28 @@ def rpath_args(self):
|
||||
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 @@ def __init__(self, path):
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user