Merge branch 'features/qt' into develop

This commit is contained in:
Todd Gamblin
2014-12-25 18:01:51 -08:00
30 changed files with 583 additions and 10 deletions

View File

@@ -30,6 +30,7 @@
import sys
import re
import shutil
import stat
import errno
import getpass
from contextlib import contextmanager, closing
@@ -63,8 +64,11 @@ def filter_file(regex, repl, *filenames, **kwargs):
# Allow strings to use \1, \2, etc. for replacement, like sed
if not callable(repl):
unescaped = repl.replace(r'\\', '\\')
repl = lambda m: re.sub(
r'\\([0-9])', lambda x: m.group(int(x.group(1))), unescaped)
def replace_groups_with_groupid(m):
def groupid_to_group(x):
return m.group(int(x.group(1)))
return re.sub(r'\\([1-9])', groupid_to_group, unescaped)
repl = replace_groups_with_groupid
if string:
regex = re.escape(regex)
@@ -142,6 +146,13 @@ def install(src, dest):
shutil.copy(src, dest)
set_install_permissions(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
if src_mode | stat.S_IXGRP: dest_mode |= stat.S_IXGRP
if src_mode | stat.S_IXOTH: dest_mode |= stat.S_IXOTH
os.chmod(dest, dest_mode)
def expand_user(path):
"""Find instances of '%u' in a path and replace with the current user's

View File

@@ -190,6 +190,7 @@ def set_module_variables_for_package(pkg):
m.makedirs = os.makedirs
m.remove = os.remove
m.removedirs = os.removedirs
m.symlink = os.symlink
m.mkdirp = mkdirp
m.install = install
@@ -199,3 +200,10 @@ def set_module_variables_for_package(pkg):
# Useful directories within the prefix are encapsulated in
# a Prefix object.
m.prefix = pkg.prefix
def setup_package(pkg):
"""Execute all environment setup routines."""
set_compiler_environment_variables(pkg)
set_build_environment_variables(pkg)
set_module_variables_for_package(pkg)

View File

@@ -0,0 +1,69 @@
##############################################################################
# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://scalability-llnl.github.io/spack
# Please also see the LICENSE file for our notice and the LGPL.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License (as published by
# the Free Software Foundation) version 2.1 dated February 1999.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
# conditions of the GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import os
from external import argparse
import llnl.util.tty as tty
import spack.cmd
import spack.build_environment as build_env
description = "Run a command with the environment for a particular spec's install."
def setup_parser(subparser):
subparser.add_argument(
'spec', nargs=argparse.REMAINDER, help="specs of package environment to emulate.")
def env(parser, args):
if not args.spec:
tty.die("spack env requires a spec.")
# Specs may have spaces in them, so if they do, require that the
# caller put a '--' between the spec and the command to be
# executed. If there is no '--', assume that the spec is the
# first argument.
sep = '--'
if sep in args.spec:
s = args.spec.index(sep)
spec = args.spec[:s]
cmd = args.spec[s+1:]
else:
spec = args.spec[0]
cmd = args.spec[1:]
specs = spack.cmd.parse_specs(spec, concretize=True)
if len(specs) > 1:
tty.die("spack env only takes one spec.")
spec = specs[0]
build_env.setup_package(spec.package)
if not cmd:
# If no command act like the "env" command and print out env vars.
for key, val in os.environ.items():
print "%s=%s" % (key, val)
else:
# Otherwise execute the command with the new environment
os.execvp(cmd[0], cmd)

View File

@@ -35,6 +35,7 @@
"""
import os
import re
import time
import inspect
import subprocess
import platform as py_platform
@@ -390,6 +391,10 @@ def ensure_has_dict(attr_name):
if not hasattr(self, 'list_depth'):
self.list_depth = 1
# Set up some internal variables for timing.
self._fetch_time = 0.0
self._total_time = 0.0
@property
def version(self):
@@ -606,6 +611,7 @@ def do_fetch(self):
if not self.spec.concrete:
raise ValueError("Can only fetch concrete packages.")
start_time = time.time()
if spack.do_checksum and not self.version in self.versions:
tty.warn("There is no checksum on file to fetch %s safely."
% self.spec.format('$_$@'))
@@ -624,6 +630,7 @@ def do_fetch(self):
"Will not fetch %s." % self.spec.format('$_$@'), checksum_msg)
self.stage.fetch()
self._fetch_time = time.time() - start_time
if spack.do_checksum and self.version in self.versions:
self.stage.check()
@@ -655,8 +662,11 @@ def do_patch(self):
# Kick off the stage first.
self.do_stage()
# Package can add its own patch function.
has_patch_fun = hasattr(self, 'patch') and callable(self.patch)
# If there are no patches, note it.
if not self.patches:
if not self.patches and not has_patch_fun:
tty.msg("No patches needed for %s." % self.name)
return
@@ -679,7 +689,7 @@ def do_patch(self):
tty.msg("Already patched %s" % self.name)
return
# Apply all the patches for specs that match this on
# Apply all the patches for specs that match this one
for spec, patch_list in self.patches.items():
if self.spec.satisfies(spec):
for patch in patch_list:
@@ -697,6 +707,11 @@ def do_patch(self):
os.remove(bad_file)
touch(good_file)
if has_patch_fun:
self.patch()
tty.msg("Patched %s" % self.name)
def do_install(self, **kwargs):
"""This class should call this version of the install method.
@@ -720,6 +735,7 @@ def do_install(self, **kwargs):
if not ignore_deps:
self.do_install_dependencies()
start_time = time.time()
if not fake_install:
self.do_patch()
@@ -742,9 +758,7 @@ def do_install(self, **kwargs):
spack.install_layout.make_path_for_spec(self.spec)
# Set up process's build environment before running install.
build_env.set_compiler_environment_variables(self)
build_env.set_build_environment_variables(self)
build_env.set_module_variables_for_package(self)
build_env.setup_package(self)
if fake_install:
mkdirp(self.prefix.bin)
@@ -765,7 +779,13 @@ def do_install(self, **kwargs):
if not keep_stage:
self.stage.destroy()
tty.msg("Successfully installed %s" % self.name)
# Stop timer.
self._total_time = time.time() - start_time
build_time = self._total_time - self._fetch_time
tty.msg("Successfully installed %s." % self.name,
"Fetch: %.2f sec. Build: %.2f sec. Total: %.2f sec."
% (self._fetch_time, build_time, self._total_time))
print_pkg(self.prefix)
# Use os._exit here to avoid raising a SystemExit exception,