init: initialize spack.store lazily

- spack.store was previously initialized at the spack.store module level,
  but this means the store has to be initialized on every spack call.

- this moves the state in spack.store to a singleton so that the store is
  only initialized when needed.
This commit is contained in:
Todd Gamblin
2018-05-10 11:45:44 -07:00
committed by scheibelp
parent c615d2be06
commit 6f2cac9565
36 changed files with 239 additions and 198 deletions

View File

@@ -50,8 +50,8 @@ class Aspell(AutotoolsPackage):
# - dest_dir instead of self.prefix in tree.(find_conflict|merge)()
def activate(self, extension, **kwargs):
extensions_layout = kwargs.get("extensions_layout",
spack.store.extensions)
if extensions_layout is not spack.store.extensions:
spack.store.store().extensions)
if extensions_layout is not spack.store.store().extensions:
raise ExtensionError(
'aspell does not support non-global extensions')
@@ -60,7 +60,7 @@ def activate(self, extension, **kwargs):
tree = LinkTree(extension.prefix.lib)
def ignore(filename):
return (filename in spack.store.layout.hidden_file_paths or
return (filename in spack.store.store().layout.hidden_file_paths or
kwargs.get('ignore', lambda f: False)(filename))
conflict = tree.find_conflict(dest_dir, ignore=ignore)
@@ -71,8 +71,8 @@ def ignore(filename):
def deactivate(self, extension, **kwargs):
extensions_layout = kwargs.get("extensions_layout",
spack.store.extensions)
if extensions_layout is not spack.store.extensions:
spack.store.store().extensions)
if extensions_layout is not spack.store.store().extensions:
raise ExtensionError(
'aspell does not support non-global extensions')
@@ -80,7 +80,7 @@ def deactivate(self, extension, **kwargs):
dest_dir = aspell('dump', 'config', 'dict-dir', output=str).strip()
def ignore(filename):
return (filename in spack.store.layout.hidden_file_paths or
return (filename in spack.store.store().layout.hidden_file_paths or
kwargs.get('ignore', lambda f: False)(filename))
tree = LinkTree(extension.prefix.lib)

View File

@@ -193,15 +193,16 @@ def set_CrayLoginNode_cmakeOptions(self, spec, cmakeOptions):
# the login node components with this spack invocation. We
# need these paths to be the ones created in the CNL
# spack invocation.
be_cbtf = spack.store.db.query_one('cbtf arch=cray-CNL-haswell')
be_cbtfk = spack.store.db.query_one('cbtf-krell arch=cray-CNL-haswell')
be_papi = spack.store.db.query_one('papi arch=cray-CNL-haswell')
be_boost = spack.store.db.query_one('boost arch=cray-CNL-haswell')
be_mont = spack.store.db.query_one('libmonitor arch=cray-CNL-haswell')
be_unw = spack.store.db.query_one('libunwind arch=cray-CNL-haswell')
be_xer = spack.store.db.query_one('xerces-c arch=cray-CNL-haswell')
be_dyn = spack.store.db.query_one('dyninst arch=cray-CNL-haswell')
be_mrnet = spack.store.db.query_one('mrnet arch=cray-CNL-haswell')
store = spack.store.store()
be_cbtf = store.db.query_one('cbtf arch=cray-CNL-haswell')
be_cbtfk = store.db.query_one('cbtf-krell arch=cray-CNL-haswell')
be_papi = store.db.query_one('papi arch=cray-CNL-haswell')
be_boost = store.db.query_one('boost arch=cray-CNL-haswell')
be_mont = store.db.query_one('libmonitor arch=cray-CNL-haswell')
be_unw = store.db.query_one('libunwind arch=cray-CNL-haswell')
be_xer = store.db.query_one('xerces-c arch=cray-CNL-haswell')
be_dyn = store.db.query_one('dyninst arch=cray-CNL-haswell')
be_mrnet = store.db.query_one('mrnet arch=cray-CNL-haswell')
CrayLoginNodeOptions.append('-DCN_RUNTIME_PLATFORM=%s'
% rt_platform)

View File

@@ -197,7 +197,8 @@ def set_CrayLoginNode_cmakeOptions(self, spec, cmakeOptions):
# spec['cbtf'].prefix is the login node value for this build, as
# we only get here when building the login node components and
# that is all that is known to spack.
be_ck = spack.store.db.query_one('cbtf-krell arch=cray-CNL-haswell')
store = spack.store.store()
be_ck = store.db.query_one('cbtf-krell arch=cray-CNL-haswell')
# Equivalent to install-tool cmake arg:
# '-DCBTF_KRELL_CN_RUNTIME_DIR=%s'

View File

@@ -264,7 +264,7 @@ def activate(self, ext_pkg, **args):
super(Perl, self).activate(ext_pkg, **args)
extensions_layout = args.get("extensions_layout",
spack.store.extensions)
spack.store.store().extensions)
exts = extensions_layout.extension_map(self.spec)
exts[ext_pkg.name] = ext_pkg.spec
@@ -276,7 +276,7 @@ def deactivate(self, ext_pkg, **args):
super(Perl, self).deactivate(ext_pkg, **args)
extensions_layout = args.get("extensions_layout",
spack.store.extensions)
spack.store.store().extensions)
exts = extensions_layout.extension_map(self.spec)
# Make deactivate idempotent

View File

@@ -320,7 +320,7 @@ def _save_distutil_vars(self, prefix):
output_filename = None
try:
output_filename = join_path(
spack.store.layout.metadata_path(self.spec),
spack.store.store().layout.metadata_path(self.spec),
Python._DISTUTIL_CACHE_FILENAME)
with open(output_filename, 'w') as output_file:
sjson.dump(self._distutil_vars, output_file)
@@ -342,7 +342,7 @@ def _load_distutil_vars(self):
if not self._distutil_vars and self.installed:
try:
input_filename = join_path(
spack.store.layout.metadata_path(self.spec),
spack.store.store().layout.metadata_path(self.spec),
Python._DISTUTIL_CACHE_FILENAME)
if os.path.isfile(input_filename):
with open(input_filename) as input_file:
@@ -680,7 +680,7 @@ def activate(self, ext_pkg, **args):
args.update(ignore=ignore)
extensions_layout = args.get("extensions_layout",
spack.store.extensions)
spack.store.store().extensions)
super(Python, self).activate(ext_pkg, **args)
@@ -696,7 +696,7 @@ def deactivate(self, ext_pkg, **args):
super(Python, self).deactivate(ext_pkg, **args)
extensions_layout = args.get("extensions_layout",
spack.store.extensions)
spack.store.store().extensions)
exts = extensions_layout.extension_map(self.spec)
# Make deactivate idempotent