summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-07-04 22:58:01 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2016-07-04 22:58:01 -0700
commit690937f9533765f6b5c2b815d9c4798f15456918 (patch)
tree51ff2e6a0b24260c51cbae3af0fcc7a31c6771f2
parent6bac1598f6778eeb23d42e0b9d072b1078290acb (diff)
downloadspack-690937f9533765f6b5c2b815d9c4798f15456918.tar.gz
spack-690937f9533765f6b5c2b815d9c4798f15456918.tar.bz2
spack-690937f9533765f6b5c2b815d9c4798f15456918.tar.xz
spack-690937f9533765f6b5c2b815d9c4798f15456918.zip
Add `--dirty` option to `spack install`.
- Allow install to be run without cleaning the environment.
-rw-r--r--lib/spack/spack/build_environment.py35
-rw-r--r--lib/spack/spack/cmd/install.py4
-rw-r--r--lib/spack/spack/package.py12
3 files changed, 32 insertions, 19 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index 7220539886..ce0b91b718 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -224,9 +224,12 @@ def set_compiler_environment_variables(pkg, env):
return env
-def set_build_environment_variables(pkg, env):
+def set_build_environment_variables(pkg, env, dirty=False):
"""
- This ensures a clean install environment when we build packages
+ This ensures a clean install environment when we build packages.
+
+ Arguments:
+ dirty -- skip unsetting the user's environment settings.
"""
# Add spack build environment path with compiler wrappers first in
# the path. We add both spack.env_path, which includes default
@@ -262,14 +265,17 @@ def set_build_environment_variables(pkg, env):
# Install root prefix
env.set(SPACK_INSTALL, spack.install_path)
- # Remove these vars from the environment during build because they
- # can affect how some packages find libraries. We want to make
- # sure that builds never pull in unintended external dependencies.
- env.unset('LD_LIBRARY_PATH')
- env.unset('LIBRARY_PATH')
- env.unset('CPATH')
- env.unset('LD_RUN_PATH')
- env.unset('DYLD_LIBRARY_PATH')
+ # Stuff in here sanitizes the build environemnt to eliminate
+ # anything the user has set that may interfere.
+ if not dirty:
+ # Remove these vars from the environment during build because they
+ # can affect how some packages find libraries. We want to make
+ # sure that builds never pull in unintended external dependencies.
+ env.unset('LD_LIBRARY_PATH')
+ env.unset('LIBRARY_PATH')
+ env.unset('CPATH')
+ env.unset('LD_RUN_PATH')
+ env.unset('DYLD_LIBRARY_PATH')
# Add bin directories from dependencies to the PATH for the build.
bin_dirs = reversed(
@@ -407,7 +413,7 @@ def load_external_modules(pkg):
load_module(dep.external_module)
-def setup_package(pkg):
+def setup_package(pkg, dirty=False):
"""Execute all environment setup routines."""
spack_env = EnvironmentModifications()
run_env = EnvironmentModifications()
@@ -430,7 +436,7 @@ def setup_package(pkg):
s.package.spec = s
set_compiler_environment_variables(pkg, spack_env)
- set_build_environment_variables(pkg, spack_env)
+ set_build_environment_variables(pkg, spack_env, dirty)
load_external_modules(pkg)
# traverse in postorder so package can use vars from its dependencies
spec = pkg.spec
@@ -459,7 +465,7 @@ def setup_package(pkg):
spack_env.apply_modifications()
-def fork(pkg, function):
+def fork(pkg, function, dirty=False):
"""Fork a child process to do part of a spack build.
Arguments:
@@ -467,6 +473,7 @@ def fork(pkg, function):
pkg -- pkg whose environemnt we should set up the
forked process for.
function -- arg-less function to run in the child process.
+ dirty -- If True, do NOT clean the environment before building.
Usage:
def child_fun():
@@ -490,7 +497,7 @@ def fork(pkg, function):
if pid == 0:
# Give the child process the package's build environment.
- setup_package(pkg)
+ setup_package(pkg, dirty=dirty)
try:
# call the forked function.
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
index 9d3175786b..3133e080d7 100644
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -54,6 +54,9 @@ def setup_parser(subparser):
'--fake', action='store_true', dest='fake',
help="Fake install. Just remove the prefix and touch a fake file in it.")
subparser.add_argument(
+ '--dirty', action='store_true', dest='dirty',
+ help="Install a package *without* cleaning the environment.")
+ subparser.add_argument(
'packages', nargs=argparse.REMAINDER, help="specs of packages to install")
@@ -79,4 +82,5 @@ def install(parser, args):
make_jobs=args.jobs,
verbose=args.verbose,
fake=args.fake,
+ dirty=args.dirty,
explicit=True)
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 53c521b776..84bd99df54 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -755,7 +755,7 @@ class Package(object):
self.stage.check()
self.stage.cache_local()
-
+
def do_stage(self, mirror_only=False):
"""Unpacks the fetched tarball, then changes into the expanded tarball
@@ -883,6 +883,7 @@ class Package(object):
make_jobs=None,
fake=False,
explicit=False,
+ dirty=False,
install_phases = install_phases):
"""Called by commands to install a package and its dependencies.
@@ -899,6 +900,7 @@ class Package(object):
fake -- Don't really build -- install fake stub files instead.
skip_patch -- Skip patch stage of build if True.
verbose -- Display verbose build output (by default, suppresses it)
+ dirty -- Don't clean the build environment before installing.
make_jobs -- Number of make jobs to use for install. Default is ncpus
"""
if not self.spec.concrete:
@@ -1037,7 +1039,7 @@ class Package(object):
pass
try:
- spack.build_environment.fork(self, build_process)
+ spack.build_environment.fork(self, build_process, dirty=dirty)
except:
# remove the install prefix if anything went wrong during install.
if not keep_prefix:
@@ -1527,15 +1529,15 @@ class StagedPackage(Package):
raise InstallError("Package %s provides no install_setup() method!" % self.name)
def install_configure(self):
- """Runs the configure process."""
+ """Runs the configure process."""
raise InstallError("Package %s provides no install_configure() method!" % self.name)
def install_build(self):
- """Runs the build process."""
+ """Runs the build process."""
raise InstallError("Package %s provides no install_build() method!" % self.name)
def install_install(self):
- """Runs the install process."""
+ """Runs the install process."""
raise InstallError("Package %s provides no install_install() method!" % self.name)
def install(self, spec, prefix):