Add --dirty
option to spack install
.
- Allow install to be run without cleaning the environment.
This commit is contained in:
parent
6bac1598f6
commit
690937f953
3 changed files with 32 additions and 19 deletions
|
@ -224,9 +224,12 @@ def set_compiler_environment_variables(pkg, env):
|
||||||
return 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
|
# Add spack build environment path with compiler wrappers first in
|
||||||
# the path. We add both spack.env_path, which includes default
|
# 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
|
# Install root prefix
|
||||||
env.set(SPACK_INSTALL, spack.install_path)
|
env.set(SPACK_INSTALL, spack.install_path)
|
||||||
|
|
||||||
# Remove these vars from the environment during build because they
|
# Stuff in here sanitizes the build environemnt to eliminate
|
||||||
# can affect how some packages find libraries. We want to make
|
# anything the user has set that may interfere.
|
||||||
# sure that builds never pull in unintended external dependencies.
|
if not dirty:
|
||||||
env.unset('LD_LIBRARY_PATH')
|
# Remove these vars from the environment during build because they
|
||||||
env.unset('LIBRARY_PATH')
|
# can affect how some packages find libraries. We want to make
|
||||||
env.unset('CPATH')
|
# sure that builds never pull in unintended external dependencies.
|
||||||
env.unset('LD_RUN_PATH')
|
env.unset('LD_LIBRARY_PATH')
|
||||||
env.unset('DYLD_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.
|
# Add bin directories from dependencies to the PATH for the build.
|
||||||
bin_dirs = reversed(
|
bin_dirs = reversed(
|
||||||
|
@ -407,7 +413,7 @@ def load_external_modules(pkg):
|
||||||
load_module(dep.external_module)
|
load_module(dep.external_module)
|
||||||
|
|
||||||
|
|
||||||
def setup_package(pkg):
|
def setup_package(pkg, dirty=False):
|
||||||
"""Execute all environment setup routines."""
|
"""Execute all environment setup routines."""
|
||||||
spack_env = EnvironmentModifications()
|
spack_env = EnvironmentModifications()
|
||||||
run_env = EnvironmentModifications()
|
run_env = EnvironmentModifications()
|
||||||
|
@ -430,7 +436,7 @@ def setup_package(pkg):
|
||||||
s.package.spec = s
|
s.package.spec = s
|
||||||
|
|
||||||
set_compiler_environment_variables(pkg, spack_env)
|
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)
|
load_external_modules(pkg)
|
||||||
# traverse in postorder so package can use vars from its dependencies
|
# traverse in postorder so package can use vars from its dependencies
|
||||||
spec = pkg.spec
|
spec = pkg.spec
|
||||||
|
@ -459,7 +465,7 @@ def setup_package(pkg):
|
||||||
spack_env.apply_modifications()
|
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.
|
"""Fork a child process to do part of a spack build.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
@ -467,6 +473,7 @@ def fork(pkg, function):
|
||||||
pkg -- pkg whose environemnt we should set up the
|
pkg -- pkg whose environemnt we should set up the
|
||||||
forked process for.
|
forked process for.
|
||||||
function -- arg-less function to run in the child process.
|
function -- arg-less function to run in the child process.
|
||||||
|
dirty -- If True, do NOT clean the environment before building.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
def child_fun():
|
def child_fun():
|
||||||
|
@ -490,7 +497,7 @@ def child_fun():
|
||||||
|
|
||||||
if pid == 0:
|
if pid == 0:
|
||||||
# Give the child process the package's build environment.
|
# Give the child process the package's build environment.
|
||||||
setup_package(pkg)
|
setup_package(pkg, dirty=dirty)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# call the forked function.
|
# call the forked function.
|
||||||
|
|
|
@ -53,6 +53,9 @@ def setup_parser(subparser):
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'--fake', action='store_true', dest='fake',
|
'--fake', action='store_true', dest='fake',
|
||||||
help="Fake install. Just remove the prefix and touch a fake file in it.")
|
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(
|
subparser.add_argument(
|
||||||
'packages', nargs=argparse.REMAINDER, help="specs of packages to install")
|
'packages', nargs=argparse.REMAINDER, help="specs of packages to install")
|
||||||
|
|
||||||
|
@ -79,4 +82,5 @@ def install(parser, args):
|
||||||
make_jobs=args.jobs,
|
make_jobs=args.jobs,
|
||||||
verbose=args.verbose,
|
verbose=args.verbose,
|
||||||
fake=args.fake,
|
fake=args.fake,
|
||||||
|
dirty=args.dirty,
|
||||||
explicit=True)
|
explicit=True)
|
||||||
|
|
|
@ -883,6 +883,7 @@ def do_install(self,
|
||||||
make_jobs=None,
|
make_jobs=None,
|
||||||
fake=False,
|
fake=False,
|
||||||
explicit=False,
|
explicit=False,
|
||||||
|
dirty=False,
|
||||||
install_phases = install_phases):
|
install_phases = install_phases):
|
||||||
"""Called by commands to install a package and its dependencies.
|
"""Called by commands to install a package and its dependencies.
|
||||||
|
|
||||||
|
@ -899,6 +900,7 @@ def do_install(self,
|
||||||
fake -- Don't really build -- install fake stub files instead.
|
fake -- Don't really build -- install fake stub files instead.
|
||||||
skip_patch -- Skip patch stage of build if True.
|
skip_patch -- Skip patch stage of build if True.
|
||||||
verbose -- Display verbose build output (by default, suppresses it)
|
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
|
make_jobs -- Number of make jobs to use for install. Default is ncpus
|
||||||
"""
|
"""
|
||||||
if not self.spec.concrete:
|
if not self.spec.concrete:
|
||||||
|
@ -1037,7 +1039,7 @@ def build_process():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
spack.build_environment.fork(self, build_process)
|
spack.build_environment.fork(self, build_process, dirty=dirty)
|
||||||
except:
|
except:
|
||||||
# remove the install prefix if anything went wrong during install.
|
# remove the install prefix if anything went wrong during install.
|
||||||
if not keep_prefix:
|
if not keep_prefix:
|
||||||
|
|
Loading…
Reference in a new issue