init: convert spack.debug global variable to config option
This commit is contained in:
parent
47dc96224d
commit
d1903f3bf3
@ -126,7 +126,3 @@
|
||||
__all__ += [
|
||||
'install_dependency_symlinks', 'flatten_dependencies',
|
||||
'DependencyConflictError', 'InstallError', 'ExternalPackageError']
|
||||
|
||||
# Add default values for attributes that would otherwise be modified from
|
||||
# Spack main script
|
||||
debug = False
|
||||
|
@ -327,7 +327,7 @@ def set_build_environment_variables(pkg, env, dirty):
|
||||
env.set_path(SPACK_ENV_PATH, env_paths)
|
||||
|
||||
# Working directory for the spack command itself, for debug logs.
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
env.set(SPACK_DEBUG, 'TRUE')
|
||||
env.set(SPACK_SHORT_SPEC, pkg.spec.short_spec)
|
||||
env.set(SPACK_DEBUG_LOG_ID, pkg.spec.format('${PACKAGE}-${HASH:7}'))
|
||||
|
@ -27,8 +27,8 @@
|
||||
import argparse
|
||||
import llnl.util.tty as tty
|
||||
|
||||
import spack
|
||||
import spack.cmd
|
||||
import spack.config
|
||||
import spack.store
|
||||
from spack.dependency import all_deptypes, canonical_deptype
|
||||
from spack.graph import graph_dot, graph_ascii
|
||||
@ -98,7 +98,8 @@ def graph(parser, args):
|
||||
graph_dot(specs, static=args.static, deptype=deptype)
|
||||
|
||||
elif specs: # ascii is default: user doesn't need to provide it explicitly
|
||||
graph_ascii(specs[0], debug=spack.debug, deptype=deptype)
|
||||
debug = spack.config.get('config:debug')
|
||||
graph_ascii(specs[0], debug=debug, deptype=deptype)
|
||||
for spec in specs[1:]:
|
||||
print() # extra line bt/w independent graphs
|
||||
graph_ascii(spec, debug=spack.debug)
|
||||
graph_ascii(spec, debug=debug)
|
||||
|
@ -110,6 +110,7 @@
|
||||
#: the defaults scope is removed.
|
||||
config_defaults = {
|
||||
'config': {
|
||||
'debug': False,
|
||||
'verify_ssl': True,
|
||||
'checksum': True,
|
||||
'dirty': False,
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
from llnl.util.filesystem import join_path, mkdirp
|
||||
|
||||
import spack
|
||||
import spack.config
|
||||
import spack.spec
|
||||
from spack.error import SpackError
|
||||
|
||||
@ -227,7 +227,7 @@ def read_spec(self, path):
|
||||
with open(path) as f:
|
||||
spec = spack.spec.Spec.from_yaml(f)
|
||||
except Exception as e:
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
raise
|
||||
raise SpecReadError(
|
||||
'Unable to read file: %s' % path, 'Cause: ' + str(e))
|
||||
|
@ -29,8 +29,6 @@
|
||||
|
||||
import llnl.util.tty as tty
|
||||
|
||||
import spack
|
||||
|
||||
|
||||
class SpackError(Exception):
|
||||
"""This is the superclass for all Spack errors.
|
||||
@ -74,7 +72,8 @@ def print_context(self):
|
||||
sys.stderr.write('\n')
|
||||
|
||||
# stack trace, etc. in debug mode.
|
||||
if spack.debug:
|
||||
import spack.config
|
||||
if spack.config.get('config:debug'):
|
||||
if self.traceback:
|
||||
# exception came from a build child, already got
|
||||
# traceback in child, so print it.
|
||||
|
@ -51,7 +51,6 @@
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.filesystem import working_dir, mkdirp, join_path
|
||||
|
||||
import spack
|
||||
import spack.config
|
||||
import spack.error
|
||||
import spack.util.crypto as crypto
|
||||
@ -649,13 +648,13 @@ def fetch(self):
|
||||
# Need to do a regular clone and check out everything if
|
||||
# they asked for a particular commit.
|
||||
with working_dir(self.stage.path):
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
git('clone', self.url)
|
||||
else:
|
||||
git('clone', '--quiet', self.url)
|
||||
|
||||
with working_dir(self.stage.source_path):
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
git('checkout', self.commit)
|
||||
else:
|
||||
git('checkout', '--quiet', self.commit)
|
||||
@ -663,7 +662,7 @@ def fetch(self):
|
||||
else:
|
||||
# Can be more efficient if not checking out a specific commit.
|
||||
args = ['clone']
|
||||
if not spack.debug:
|
||||
if not spack.config.get('config:debug'):
|
||||
args.append('--quiet')
|
||||
|
||||
# If we want a particular branch ask for it.
|
||||
@ -701,7 +700,7 @@ def fetch(self):
|
||||
# pull --tags returns a "special" error code of 1 in
|
||||
# older versions that we have to ignore.
|
||||
# see: https://github.com/git/git/commit/19d122b
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
git('pull', '--tags', ignore_errors=1)
|
||||
git('checkout', self.tag)
|
||||
else:
|
||||
@ -711,7 +710,7 @@ def fetch(self):
|
||||
with working_dir(self.stage.source_path):
|
||||
# Init submodules if the user asked for them.
|
||||
if self.submodules:
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
git('submodule', 'update', '--init', '--recursive')
|
||||
else:
|
||||
git('submodule', '--quiet', 'update', '--init',
|
||||
@ -723,7 +722,7 @@ def archive(self, destination):
|
||||
@_needs_stage
|
||||
def reset(self):
|
||||
with working_dir(self.stage.source_path):
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
self.git('checkout', '.')
|
||||
self.git('clean', '-f')
|
||||
else:
|
||||
|
@ -345,11 +345,11 @@ def setup_main_options(args):
|
||||
tty.set_verbose(args.verbose)
|
||||
tty.set_debug(args.debug)
|
||||
tty.set_stacktrace(args.stacktrace)
|
||||
spack.debug = args.debug
|
||||
|
||||
if spack.debug:
|
||||
if args.debug:
|
||||
import spack.util.debug as debug
|
||||
debug.register_interrupt_handler()
|
||||
spack.config.set('config:debug', True, scope='command_line')
|
||||
|
||||
if args.mock:
|
||||
from spack.repository import RepoPath
|
||||
@ -476,7 +476,7 @@ def _main(command, parser, args, unknown_args):
|
||||
except SpackError as e:
|
||||
e.die() # gracefully die on any SpackErrors
|
||||
except Exception as e:
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
raise
|
||||
tty.die(str(e))
|
||||
except KeyboardInterrupt:
|
||||
@ -554,7 +554,7 @@ def main(argv=None):
|
||||
try:
|
||||
parser.add_command(cmd_name)
|
||||
except ImportError:
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
raise
|
||||
tty.die("Unknown command: %s" % args.command[0])
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
import llnl.util.tty as tty
|
||||
from llnl.util.filesystem import mkdirp, join_path
|
||||
|
||||
import spack
|
||||
import spack.config
|
||||
import spack.error
|
||||
import spack.url as url
|
||||
import spack.fetch_strategy as fs
|
||||
@ -255,7 +255,7 @@ def add_single_spec(spec, mirror_root, categories, **kwargs):
|
||||
categories['mirrored'].append(spec)
|
||||
|
||||
except Exception as e:
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
sys.excepthook(*sys.exc_info())
|
||||
else:
|
||||
tty.warn(
|
||||
|
@ -48,6 +48,7 @@
|
||||
from llnl.util.filesystem import mkdirp, join_path, install
|
||||
|
||||
import spack
|
||||
import spack.config
|
||||
import spack.caches
|
||||
import spack.error
|
||||
import spack.spec
|
||||
@ -835,7 +836,7 @@ def get(self, spec):
|
||||
try:
|
||||
return package_class(spec)
|
||||
except Exception:
|
||||
if spack.debug:
|
||||
if spack.config.get('config:debug'):
|
||||
sys.excepthook(*sys.exc_info())
|
||||
raise FailedConstructorError(spec.fullname, *sys.exc_info())
|
||||
|
||||
|
@ -64,6 +64,7 @@
|
||||
'source_cache': {'type': 'string'},
|
||||
'misc_cache': {'type': 'string'},
|
||||
'verify_ssl': {'type': 'boolean'},
|
||||
'debug': {'type': 'boolean'},
|
||||
'checksum': {'type': 'boolean'},
|
||||
'dirty': {'type': 'boolean'},
|
||||
'build_jobs': {'type': 'integer', 'minimum': 1},
|
||||
|
Loading…
Reference in New Issue
Block a user