Add --dirty option to spack install.
				
					
				
			- Allow install to be run without cleaning the environment.
This commit is contained in:
		| @@ -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 child_fun(): | ||||
|  | ||||
|     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. | ||||
|   | ||||
| @@ -53,6 +53,9 @@ def setup_parser(subparser): | ||||
|     subparser.add_argument( | ||||
|         '--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) | ||||
|   | ||||
| @@ -755,7 +755,7 @@ def do_fetch(self, mirror_only=False): | ||||
|             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 @@ def do_install(self, | ||||
|                    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 @@ def do_install(self, | ||||
|         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 @@ def build_process(): | ||||
|                 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 @@ def install_setup(self): | ||||
|         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): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Todd Gamblin
					Todd Gamblin