summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-04-27 14:58:54 -0700
committerscheibelp <scheibel1@llnl.gov>2018-05-17 14:10:30 -0700
commitd1903f3bf3740c0e4930dae1e89a2322a7541f47 (patch)
treedf0a1932d1faa6218244e2711084814e736ad376 /lib
parent47dc96224d575633653391192522a3807739c477 (diff)
downloadspack-d1903f3bf3740c0e4930dae1e89a2322a7541f47.tar.gz
spack-d1903f3bf3740c0e4930dae1e89a2322a7541f47.tar.bz2
spack-d1903f3bf3740c0e4930dae1e89a2322a7541f47.tar.xz
spack-d1903f3bf3740c0e4930dae1e89a2322a7541f47.zip
init: convert spack.debug global variable to config option
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/__init__.py4
-rw-r--r--lib/spack/spack/build_environment.py2
-rw-r--r--lib/spack/spack/cmd/graph.py7
-rw-r--r--lib/spack/spack/config.py1
-rw-r--r--lib/spack/spack/directory_layout.py4
-rw-r--r--lib/spack/spack/error.py5
-rw-r--r--lib/spack/spack/fetch_strategy.py13
-rw-r--r--lib/spack/spack/main.py8
-rw-r--r--lib/spack/spack/mirror.py4
-rw-r--r--lib/spack/spack/repository.py3
-rw-r--r--lib/spack/spack/schema/config.py1
11 files changed, 25 insertions, 27 deletions
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index 05cfa4af58..4dc07d43fe 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -126,7 +126,3 @@ from spack.package import \
__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
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index d4f6e36e56..7a2e2e5094 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -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}'))
diff --git a/lib/spack/spack/cmd/graph.py b/lib/spack/spack/cmd/graph.py
index dab99038be..305835ff34 100644
--- a/lib/spack/spack/cmd/graph.py
+++ b/lib/spack/spack/cmd/graph.py
@@ -27,8 +27,8 @@ from __future__ import print_function
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)
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index bbc344ebd8..5a551bdc42 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -110,6 +110,7 @@ configuration_paths = (
#: the defaults scope is removed.
config_defaults = {
'config': {
+ 'debug': False,
'verify_ssl': True,
'checksum': True,
'dirty': False,
diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py
index dace4002d6..6c38b9f077 100644
--- a/lib/spack/spack/directory_layout.py
+++ b/lib/spack/spack/directory_layout.py
@@ -31,7 +31,7 @@ import re
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 @@ class YamlDirectoryLayout(DirectoryLayout):
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))
diff --git a/lib/spack/spack/error.py b/lib/spack/spack/error.py
index 3beb5a187a..327b97b5d6 100644
--- a/lib/spack/spack/error.py
+++ b/lib/spack/spack/error.py
@@ -29,8 +29,6 @@ import inspect
import llnl.util.tty as tty
-import spack
-
class SpackError(Exception):
"""This is the superclass for all Spack errors.
@@ -74,7 +72,8 @@ class SpackError(Exception):
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.
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index e1cc30c65c..7931dd65d2 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -51,7 +51,6 @@ from six import string_types, with_metaclass
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 @@ class GitFetchStrategy(VCSFetchStrategy):
# 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 @@ class GitFetchStrategy(VCSFetchStrategy):
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 @@ class GitFetchStrategy(VCSFetchStrategy):
# 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 @@ class GitFetchStrategy(VCSFetchStrategy):
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 @@ class GitFetchStrategy(VCSFetchStrategy):
@_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:
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py
index 62ecec5592..6a2a1e2470 100644
--- a/lib/spack/spack/main.py
+++ b/lib/spack/spack/main.py
@@ -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])
diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py
index 5b9b22b754..56b02831d6 100644
--- a/lib/spack/spack/mirror.py
+++ b/lib/spack/spack/mirror.py
@@ -35,7 +35,7 @@ import os
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(
diff --git a/lib/spack/spack/repository.py b/lib/spack/spack/repository.py
index a50f23b609..b1a6c78249 100644
--- a/lib/spack/spack/repository.py
+++ b/lib/spack/spack/repository.py
@@ -48,6 +48,7 @@ import llnl.util.tty as tty
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 @@ class Repo(object):
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())
diff --git a/lib/spack/spack/schema/config.py b/lib/spack/spack/schema/config.py
index 5a60f71f9d..d38e31cfd2 100644
--- a/lib/spack/spack/schema/config.py
+++ b/lib/spack/spack/schema/config.py
@@ -64,6 +64,7 @@ schema = {
'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},