diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2018-04-15 22:45:40 -0700 |
---|---|---|
committer | scheibelp <scheibel1@llnl.gov> | 2018-05-17 14:10:30 -0700 |
commit | 2ab7b7a5a0533739f7e4a4cef7eb4336c795f514 (patch) | |
tree | fb40e5131a3b729114a980cc118bfb60440d473c /lib | |
parent | 278933e824d6ef0b791ec088070b86ed3c1f03b5 (diff) | |
download | spack-2ab7b7a5a0533739f7e4a4cef7eb4336c795f514.tar.gz spack-2ab7b7a5a0533739f7e4a4cef7eb4336c795f514.tar.bz2 spack-2ab7b7a5a0533739f7e4a4cef7eb4336c795f514.tar.xz spack-2ab7b7a5a0533739f7e4a4cef7eb4336c795f514.zip |
init: convert spack.dirty global to config option
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/__init__.py | 5 | ||||
-rw-r--r-- | lib/spack/spack/cmd/common/arguments.py | 35 | ||||
-rw-r--r-- | lib/spack/spack/cmd/patch.py | 1 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/install.py | 5 |
4 files changed, 12 insertions, 34 deletions
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py index 6cdfd4c72e..ac35e79d80 100644 --- a/lib/spack/spack/__init__.py +++ b/lib/spack/spack/__init__.py @@ -44,11 +44,6 @@ import spack.config binary_cache_retrieved_specs = set() -# If this is True, spack will not clean the environment to remove -# potentially harmful variables before builds. -dirty = spack.config.get('config:dirty', False) - - #: The number of jobs to use when building in parallel. #: By default, use all cores on the machine. build_jobs = spack.config.get('config:build_jobs', multiprocessing.cpu_count()) diff --git a/lib/spack/spack/cmd/common/arguments.py b/lib/spack/spack/cmd/common/arguments.py index 9e58828560..ea5bc1c25d 100644 --- a/lib/spack/spack/cmd/common/arguments.py +++ b/lib/spack/spack/cmd/common/arguments.py @@ -26,6 +26,7 @@ import argparse import spack.cmd +import spack.config import spack.modules import spack.spec import spack.store @@ -52,7 +53,7 @@ def add_common_arguments(parser, list_of_arguments): class ConstraintAction(argparse.Action): - """Constructs a list of specs based on a constraint given on the command line + """Constructs a list of specs based on constraints from the command line An instance of this class is supposed to be used as an argument action in a parser. It will read a constraint and will attach a function to the @@ -82,23 +83,6 @@ class ConstraintAction(argparse.Action): return sorted(specs) -class CleanOrDirtyAction(argparse.Action): - """Sets the dirty flag in the current namespace""" - - def __init__(self, *args, **kwargs): - kwargs['default'] = spack.dirty - super(CleanOrDirtyAction, self).__init__(*args, **kwargs) - - def __call__(self, parser, namespace, values, option_string=None): - if option_string == '--clean': - setattr(namespace, self.dest, False) - elif option_string == '--dirty': - setattr(namespace, self.dest, True) - else: - msg = 'expected "--dirty" or "--clean" [got {0} instead]' - raise argparse.ArgumentError(msg.format(option_string)) - - _arguments['constraint'] = Args( 'constraint', nargs=argparse.REMAINDER, action=ConstraintAction, help='constraint to select a subset of installed packages') @@ -107,7 +91,7 @@ _arguments['module_type'] = Args( '-m', '--module-type', choices=spack.modules.module_types.keys(), action='append', - help='type of module file. More than one choice is allowed [default: tcl]') # NOQA: ignore=E501 + help='type of module file. More than one choice is allowed [default: tcl]') _arguments['yes_to_all'] = Args( '-y', '--yes-to-all', action='store_true', dest='yes_to_all', @@ -119,18 +103,17 @@ _arguments['recurse_dependencies'] = Args( _arguments['clean'] = Args( '--clean', - action=CleanOrDirtyAction, + action='store_false', + default=spack.config.get('config:dirty'), dest='dirty', - help='sanitize the environment from variables that can affect how ' + - ' packages find libraries or headers', - nargs=0) + help='unset harmful variables in the build environment (default)') _arguments['dirty'] = Args( '--dirty', - action=CleanOrDirtyAction, + action='store_true', + default=spack.config.get('config:dirty'), dest='dirty', - help='maintain the current environment without trying to sanitize it', - nargs=0) + help='preserve user environment in the spack build environment (danger!)') _arguments['long'] = Args( '-l', '--long', action='store_true', diff --git a/lib/spack/spack/cmd/patch.py b/lib/spack/spack/cmd/patch.py index edadb75657..efc55667c5 100644 --- a/lib/spack/spack/cmd/patch.py +++ b/lib/spack/spack/cmd/patch.py @@ -31,7 +31,6 @@ import spack.cmd import spack.cmd.common.arguments as arguments - description = "patch expanded archive sources in preparation for install" section = "build" level = "long" diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index 5b81e37e8a..f9d2ad74cc 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -31,8 +31,9 @@ import pytest import llnl.util.filesystem as fs import spack -import spack.cmd.install +import spack.config import spack.package +import spack.cmd.install from spack.error import SpackError from spack.spec import Spec from spack.main import SpackCommand @@ -125,7 +126,7 @@ def test_install_package_already_installed( @pytest.mark.parametrize('arguments,expected', [ - ([], spack.dirty), # The default read from configuration file + ([], spack.config.get('config:dirty')), # default from config file (['--clean'], False), (['--dirty'], True), ]) |