summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-03-13 23:41:59 -0400
committerTodd Gamblin <tgamblin@llnl.gov>2015-03-13 23:41:59 -0400
commit1414480d3afca4a568821bc7d0892a1571b44d6b (patch)
tree64d4b74bc5ac6f02a31e5398041c45d1c464920a /lib
parent8eab69fc0b06994ad063efec4d40c418aef49a10 (diff)
parent32244ac733f6276e50511e42620b49be90f72f0b (diff)
downloadspack-1414480d3afca4a568821bc7d0892a1571b44d6b.tar.gz
spack-1414480d3afca4a568821bc7d0892a1571b44d6b.tar.bz2
spack-1414480d3afca4a568821bc7d0892a1571b44d6b.tar.xz
spack-1414480d3afca4a568821bc7d0892a1571b44d6b.zip
Merge develop for v0.8.16 release.v0.8.16
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/docs/site_configuration.rst5
l---------lib/spack/env/clang1
l---------lib/spack/env/clang++1
l---------lib/spack/env/g++1
l---------lib/spack/env/gcc1
-rw-r--r--lib/spack/llnl/util/filesystem.py121
-rw-r--r--lib/spack/llnl/util/link_tree.py82
-rw-r--r--lib/spack/spack/build_environment.py25
-rw-r--r--lib/spack/spack/package.py32
9 files changed, 152 insertions, 117 deletions
diff --git a/lib/spack/docs/site_configuration.rst b/lib/spack/docs/site_configuration.rst
index 44071bbfc6..b03df29573 100644
--- a/lib/spack/docs/site_configuration.rst
+++ b/lib/spack/docs/site_configuration.rst
@@ -8,8 +8,9 @@ Site configuration
Temporary space
----------------------------
-.. warning:: Temporary space configuration will be moved to configuration files.
- The instructions here are old and refer to ``__init__.py``
+.. warning:: Temporary space configuration will eventually be moved to
+ configuration files, but currently these settings are in
+ ``lib/spack/spack/__init__.py``
By default, Spack will try to do all of its building in temporary
space. There are two main reasons for this. First, Spack is designed
diff --git a/lib/spack/env/clang b/lib/spack/env/clang
deleted file mode 120000
index 2652f5f42c..0000000000
--- a/lib/spack/env/clang
+++ /dev/null
@@ -1 +0,0 @@
-cc \ No newline at end of file
diff --git a/lib/spack/env/clang++ b/lib/spack/env/clang++
deleted file mode 120000
index 2652f5f42c..0000000000
--- a/lib/spack/env/clang++
+++ /dev/null
@@ -1 +0,0 @@
-cc \ No newline at end of file
diff --git a/lib/spack/env/g++ b/lib/spack/env/g++
deleted file mode 120000
index 2652f5f42c..0000000000
--- a/lib/spack/env/g++
+++ /dev/null
@@ -1 +0,0 @@
-cc \ No newline at end of file
diff --git a/lib/spack/env/gcc b/lib/spack/env/gcc
deleted file mode 120000
index 2652f5f42c..0000000000
--- a/lib/spack/env/gcc
+++ /dev/null
@@ -1 +0,0 @@
-cc \ No newline at end of file
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index 576aeb16bd..1fdd25f608 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -22,9 +22,10 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-__all__ = ['set_install_permissions', 'install', 'expand_user', 'working_dir',
- 'touch', 'touchp', 'mkdirp', 'force_remove', 'join_path', 'ancestor',
- 'can_access', 'filter_file', 'change_sed_delimiter', 'is_exe']
+__all__ = ['set_install_permissions', 'install', 'install_tree', 'traverse_tree',
+ 'expand_user', 'working_dir', 'touch', 'touchp', 'mkdirp',
+ 'force_remove', 'join_path', 'ancestor', 'can_access', 'filter_file',
+ 'change_sed_delimiter', 'is_exe', 'force_symlink']
import os
import sys
@@ -140,12 +141,7 @@ def set_install_permissions(path):
os.chmod(path, 0644)
-def install(src, dest):
- """Manually install a file to a particular location."""
- tty.info("Installing %s to %s" % (src, dest))
- shutil.copy(src, dest)
- set_install_permissions(dest)
-
+def copy_mode(src, dest):
src_mode = os.stat(src).st_mode
dest_mode = os.stat(dest).st_mode
if src_mode | stat.S_IXUSR: dest_mode |= stat.S_IXUSR
@@ -154,6 +150,24 @@ def install(src, dest):
os.chmod(dest, dest_mode)
+def install(src, dest):
+ """Manually install a file to a particular location."""
+ tty.info("Installing %s to %s" % (src, dest))
+ shutil.copy(src, dest)
+ set_install_permissions(dest)
+ copy_mode(src, dest)
+
+
+def install_tree(src, dest, **kwargs):
+ """Manually install a file to a particular location."""
+ tty.info("Installing %s to %s" % (src, dest))
+ shutil.copytree(src, dest, **kwargs)
+
+ for s, d in traverse_tree(src, dest, follow_nonexisting=False):
+ set_install_permissions(d)
+ copy_mode(s, d)
+
+
def is_exe(path):
"""True if path is an executable file."""
return os.path.isfile(path) and os.access(path, os.X_OK)
@@ -210,6 +224,14 @@ def touchp(path):
touch(path)
+def force_symlink(src, dest):
+ try:
+ os.symlink(src, dest)
+ except OSError, e:
+ os.remove(dest)
+ os.symlink(src, dest)
+
+
def join_path(prefix, *args):
path = str(prefix)
for elt in args:
@@ -228,3 +250,84 @@ def ancestor(dir, n=1):
def can_access(file_name):
"""True if we have read/write access to the file."""
return os.access(file_name, os.R_OK|os.W_OK)
+
+
+def traverse_tree(source_root, dest_root, rel_path='', **kwargs):
+ """Traverse two filesystem trees simultaneously.
+
+ Walks the LinkTree directory in pre or post order. Yields each
+ file in the source directory with a matching path from the dest
+ directory, along with whether the file is a directory.
+ e.g., for this tree::
+
+ root/
+ a/
+ file1
+ file2
+ b/
+ file3
+
+ When called on dest, this yields::
+
+ ('root', 'dest')
+ ('root/a', 'dest/a')
+ ('root/a/file1', 'dest/a/file1')
+ ('root/a/file2', 'dest/a/file2')
+ ('root/b', 'dest/b')
+ ('root/b/file3', 'dest/b/file3')
+
+ Optional args:
+
+ order=[pre|post] -- Whether to do pre- or post-order traveral.
+
+ ignore=<predicate> -- Predicate indicating which files to ignore.
+
+ follow_nonexisting -- Whether to descend into directories in
+ src that do not exit in dest. Default True.
+
+ follow_links -- Whether to descend into symlinks in src.
+
+ """
+ follow_nonexisting = kwargs.get('follow_nonexisting', True)
+ follow_links = kwargs.get('follow_link', False)
+
+ # Yield in pre or post order?
+ order = kwargs.get('order', 'pre')
+ if order not in ('pre', 'post'):
+ raise ValueError("Order must be 'pre' or 'post'.")
+
+ # List of relative paths to ignore under the src root.
+ ignore = kwargs.get('ignore', lambda filename: False)
+
+ # Don't descend into ignored directories
+ if ignore(rel_path):
+ return
+
+ source_path = os.path.join(source_root, rel_path)
+ dest_path = os.path.join(dest_root, rel_path)
+
+ # preorder yields directories before children
+ if order == 'pre':
+ yield (source_path, dest_path)
+
+ for f in os.listdir(source_path):
+ source_child = os.path.join(source_path, f)
+ dest_child = os.path.join(dest_path, f)
+ rel_child = os.path.join(rel_path, f)
+
+ # Treat as a directory
+ if os.path.isdir(source_child) and (
+ follow_links or not os.path.islink(source_child)):
+
+ # When follow_nonexisting isn't set, don't descend into dirs
+ # in source that do not exist in dest
+ if follow_nonexisting or os.path.exists(dest_child):
+ tuples = traverse_tree(source_root, dest_root, rel_child, **kwargs)
+ for t in tuples: yield t
+
+ # Treat as a file.
+ elif not ignore(os.path.join(rel_path, f)):
+ yield (source_child, dest_child)
+
+ if order == 'post':
+ yield (source_path, dest_path)
diff --git a/lib/spack/llnl/util/link_tree.py b/lib/spack/llnl/util/link_tree.py
index 4d778eca1e..583f077b79 100644
--- a/lib/spack/llnl/util/link_tree.py
+++ b/lib/spack/llnl/util/link_tree.py
@@ -32,88 +32,6 @@ from llnl.util.filesystem import *
empty_file_name = '.spack-empty'
-def traverse_tree(source_root, dest_root, rel_path='', **kwargs):
- """Traverse two filesystem trees simultaneously.
-
- Walks the LinkTree directory in pre or post order. Yields each
- file in the source directory with a matching path from the dest
- directory, along with whether the file is a directory.
- e.g., for this tree::
-
- root/
- a/
- file1
- file2
- b/
- file3
-
- When called on dest, this yields::
-
- ('root', 'dest')
- ('root/a', 'dest/a')
- ('root/a/file1', 'dest/a/file1')
- ('root/a/file2', 'dest/a/file2')
- ('root/b', 'dest/b')
- ('root/b/file3', 'dest/b/file3')
-
- Optional args:
-
- order=[pre|post] -- Whether to do pre- or post-order traveral.
-
- ignore=<predicate> -- Predicate indicating which files to ignore.
-
- follow_nonexisting -- Whether to descend into directories in
- src that do not exit in dest. Default True.
-
- follow_links -- Whether to descend into symlinks in src.
-
- """
- follow_nonexisting = kwargs.get('follow_nonexisting', True)
- follow_links = kwargs.get('follow_link', False)
-
- # Yield in pre or post order?
- order = kwargs.get('order', 'pre')
- if order not in ('pre', 'post'):
- raise ValueError("Order must be 'pre' or 'post'.")
-
- # List of relative paths to ignore under the src root.
- ignore = kwargs.get('ignore', lambda filename: False)
-
- # Don't descend into ignored directories
- if ignore(rel_path):
- return
-
- source_path = os.path.join(source_root, rel_path)
- dest_path = os.path.join(dest_root, rel_path)
-
- # preorder yields directories before children
- if order == 'pre':
- yield (source_path, dest_path)
-
- for f in os.listdir(source_path):
- source_child = os.path.join(source_path, f)
- dest_child = os.path.join(dest_path, f)
- rel_child = os.path.join(rel_path, f)
-
- # Treat as a directory
- if os.path.isdir(source_child) and (
- follow_links or not os.path.islink(source_child)):
-
- # When follow_nonexisting isn't set, don't descend into dirs
- # in source that do not exist in dest
- if follow_nonexisting or os.path.exists(dest_child):
- tuples = traverse_tree(source_root, dest_root, rel_child, **kwargs)
- for t in tuples: yield t
-
- # Treat as a file.
- elif not ignore(os.path.join(rel_path, f)):
- yield (source_child, dest_child)
-
- if order == 'post':
- yield (source_path, dest_path)
-
-
-
class LinkTree(object):
"""Class to create trees of symbolic links from a source directory.
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index 59b25d96e7..d11e2e270c 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -189,18 +189,19 @@ def set_module_variables_for_package(pkg):
m.std_cmake_args.append('-DCMAKE_INSTALL_RPATH=%s' % ":".join(get_rpaths(pkg)))
# Emulate some shell commands for convenience
- m.pwd = os.getcwd
- m.cd = os.chdir
- m.mkdir = os.mkdir
- m.makedirs = os.makedirs
- m.remove = os.remove
- m.removedirs = os.removedirs
- m.symlink = os.symlink
-
- m.mkdirp = mkdirp
- m.install = install
- m.rmtree = shutil.rmtree
- m.move = shutil.move
+ m.pwd = os.getcwd
+ m.cd = os.chdir
+ m.mkdir = os.mkdir
+ m.makedirs = os.makedirs
+ m.remove = os.remove
+ m.removedirs = os.removedirs
+ m.symlink = os.symlink
+
+ m.mkdirp = mkdirp
+ m.install = install
+ m.install_tree = install_tree
+ m.rmtree = shutil.rmtree
+ m.move = shutil.move
# Useful directories within the prefix are encapsulated in
# a Prefix object.
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 75e6142a9d..36f1e8a777 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -62,6 +62,7 @@ from spack.version import *
from spack.stage import Stage
from spack.util.web import get_pages
from spack.util.compression import allowed_archive, extension
+from spack.util.executable import ProcessError
"""Allowed URL schemes for spack packages."""
_ALLOWED_URL_SCHEMES = ["http", "https", "ftp", "file", "git"]
@@ -805,6 +806,16 @@ class Package(object):
# package naming scheme it likes.
spack.install_layout.make_path_for_spec(self.spec)
+ def cleanup():
+ if not keep_prefix:
+ # If anything goes wrong, remove the install prefix
+ self.remove_prefix()
+ else:
+ tty.warn("Keeping install prefix in place despite error.",
+ "Spack will think this package is installed." +
+ "Manually remove this directory to fix:",
+ self.prefix)
+
def real_work():
try:
tty.msg("Building %s." % self.name)
@@ -837,15 +848,20 @@ class Package(object):
% (_hms(self._fetch_time), _hms(build_time), _hms(self._total_time)))
print_pkg(self.prefix)
- except:
- if not keep_prefix:
- # If anything goes wrong, remove the install prefix
- self.remove_prefix()
+ except ProcessError, e:
+ # One of the processes returned an error code.
+ # Suppress detailed stack trace here unless in debug mode
+ if spack.debug:
+ raise e
else:
- tty.warn("Keeping install prefix in place despite error.",
- "Spack will think this package is installed." +
- "Manually remove this directory to fix:",
- self.prefix)
+ tty.error(e)
+
+ # Still need to clean up b/c there was an error.
+ cleanup()
+
+ except:
+ # other exceptions just clean up and raise.
+ cleanup()
raise
build_env.fork(self, real_work)