From 6f2cac9565cd50cded141533b1594faa02c4b2f6 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Thu, 10 May 2018 11:45:44 -0700 Subject: 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. --- var/spack/repos/builtin/packages/aspell/package.py | 12 ++++++------ .../repos/builtin/packages/cbtf-krell/package.py | 19 ++++++++++--------- .../repos/builtin/packages/openspeedshop/package.py | 3 ++- var/spack/repos/builtin/packages/perl/package.py | 4 ++-- var/spack/repos/builtin/packages/python/package.py | 8 ++++---- 5 files changed, 24 insertions(+), 22 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/aspell/package.py b/var/spack/repos/builtin/packages/aspell/package.py index 66eeb9e7cb..1b23258099 100644 --- a/var/spack/repos/builtin/packages/aspell/package.py +++ b/var/spack/repos/builtin/packages/aspell/package.py @@ -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 @@ class Aspell(AutotoolsPackage): 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 @@ class Aspell(AutotoolsPackage): 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 @@ class Aspell(AutotoolsPackage): 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) diff --git a/var/spack/repos/builtin/packages/cbtf-krell/package.py b/var/spack/repos/builtin/packages/cbtf-krell/package.py index 15ea33dd79..9ec7853abf 100644 --- a/var/spack/repos/builtin/packages/cbtf-krell/package.py +++ b/var/spack/repos/builtin/packages/cbtf-krell/package.py @@ -193,15 +193,16 @@ class CbtfKrell(CMakePackage): # 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) diff --git a/var/spack/repos/builtin/packages/openspeedshop/package.py b/var/spack/repos/builtin/packages/openspeedshop/package.py index 237784e42d..2663a3ff33 100644 --- a/var/spack/repos/builtin/packages/openspeedshop/package.py +++ b/var/spack/repos/builtin/packages/openspeedshop/package.py @@ -197,7 +197,8 @@ class Openspeedshop(CMakePackage): # 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' diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py index 1759c15d86..192e31f32f 100644 --- a/var/spack/repos/builtin/packages/perl/package.py +++ b/var/spack/repos/builtin/packages/perl/package.py @@ -264,7 +264,7 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package 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 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package 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 diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py index 34e1e0ea6d..b2ca9a29b4 100644 --- a/var/spack/repos/builtin/packages/python/package.py +++ b/var/spack/repos/builtin/packages/python/package.py @@ -320,7 +320,7 @@ class Python(AutotoolsPackage): 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 @@ class Python(AutotoolsPackage): 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 @@ class Python(AutotoolsPackage): 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 @@ class Python(AutotoolsPackage): 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 -- cgit v1.2.3-70-g09d2