Skip to content

Commit

Permalink
Merge develop for v0.8.16 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgamblin committed Mar 14, 2015
2 parents 8eab69f + 32244ac commit 1414480
Show file tree
Hide file tree
Showing 17 changed files with 305 additions and 125 deletions.
5 changes: 3 additions & 2 deletions lib/spack/docs/site_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion lib/spack/env/clang

This file was deleted.

1 change: 0 additions & 1 deletion lib/spack/env/clang++

This file was deleted.

1 change: 0 additions & 1 deletion lib/spack/env/g++

This file was deleted.

1 change: 0 additions & 1 deletion lib/spack/env/gcc

This file was deleted.

121 changes: 112 additions & 9 deletions lib/spack/llnl/util/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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)
82 changes: 0 additions & 82 deletions lib/spack/llnl/util/link_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,88 +32,6 @@
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.
Expand Down
25 changes: 13 additions & 12 deletions lib/spack/spack/build_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 24 additions & 8 deletions lib/spack/spack/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
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"]
Expand Down Expand Up @@ -805,6 +806,16 @@ def do_install(self, **kwargs):
# 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)
Expand Down Expand Up @@ -837,15 +848,20 @@ def real_work():
% (_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)
Expand Down
18 changes: 11 additions & 7 deletions var/spack/packages/SAMRAI/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ class Samrai(Package):
structured adaptive mesh refinement (SAMR) technology in large-scale parallel
application development.
"""
homepage = "https://computation-rnd.llnl.gov/SAMRAI/confirm.php"
url = "https://computation-rnd.llnl.gov/SAMRAI/download/SAMRAI-v3.7.3.tar.gz"
homepage = "https://computation.llnl.gov/project/SAMRAI/"
url = "https://computation.llnl.gov/project/SAMRAI/download/SAMRAI-v3.9.1.tar.gz"
list_url = homepage

version('3.9.1', '232d04d0c995f5abf20d94350befd0b2')
version('3.7.3', '12d574eacadf8c9a70f1bb4cd1a69df6')
version('3.7.2', 'f6a716f171c9fdbf3cb12f71fa6e2737')
version('3.6.3-beta', 'ef0510bf2893042daedaca434e5ec6ce')
Expand All @@ -24,22 +25,25 @@ class Samrai(Package):
depends_on("mpi")
depends_on("zlib")
depends_on("hdf5")
depends_on("boost@1.52.0")
depends_on("boost")

# don't build tools with gcc
patch('no-tool-build.patch', when='%gcc')

# TODO: currently hard-coded to use openmpi - be careful!
def install(self, spec, prefix):
mpi = next(m for m in ('openmpi', 'mpich', 'mvapich')
if m in spec)

configure(
"--prefix=%s" % prefix,
"--with-CXX=%s" % spec['openmpi'].prefix.bin + "/mpic++",
"--with-CC=%s" % spec['openmpi'].prefix.bin + "/mpicc",
"--with-CXX=%s" % spec[mpi].prefix.bin + "/mpic++",
"--with-CC=%s" % spec[mpi].prefix.bin + "/mpicc",
"--with-hdf5=%s" % spec['hdf5'].prefix,
"--with-boost=%s" % spec['boost'].prefix,
"--with-zlib=%s" % spec['zlib'].prefix,
"--disable-blas",
"--disable-lapack",
"--without-blas",
"--without-lapack",
"--with-hypre=no",
"--with-petsc=no",
"--enable-opt",
Expand Down
Loading

0 comments on commit 1414480

Please sign in to comment.