diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2018-05-16 10:57:40 -0700 |
---|---|---|
committer | scheibelp <scheibel1@llnl.gov> | 2018-05-17 14:10:30 -0700 |
commit | f202198777b4353c57c26fa87739b306070fd960 (patch) | |
tree | 325c7fa10d591359650eb9f87e970d03df55f669 /var | |
parent | 3493f7e793e5bf5fdc0c51978ea476185025c192 (diff) | |
download | spack-f202198777b4353c57c26fa87739b306070fd960.tar.gz spack-f202198777b4353c57c26fa87739b306070fd960.tar.bz2 spack-f202198777b4353c57c26fa87739b306070fd960.tar.xz spack-f202198777b4353c57c26fa87739b306070fd960.zip |
Convert lazy singleton functions to Singleton object
- simplify the singleton pattern across the codebase
- reduce lines of code needed for crufty initialization
- reduce functions that need to mess with a global
- Singletons whose semantics changed:
- spack.store.store() -> spack.store
- spack.repo.path() -> spack.repo.path
- spack.config.config() -> spack.config.config
- spack.caches.fetch_cache() -> spack.caches.fetch_cache
- spack.caches.misc_cache() -> spack.caches.misc_cache
Diffstat (limited to 'var')
5 files changed, 14 insertions, 14 deletions
diff --git a/var/spack/repos/builtin/packages/aspell/package.py b/var/spack/repos/builtin/packages/aspell/package.py index 1b23258099..66eeb9e7cb 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.store().extensions) - if extensions_layout is not spack.store.store().extensions: + spack.store.extensions) + if extensions_layout is not spack.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.store().layout.hidden_file_paths or + return (filename in spack.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.store().extensions) - if extensions_layout is not spack.store.store().extensions: + spack.store.extensions) + if extensions_layout is not spack.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.store().layout.hidden_file_paths or + return (filename in spack.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 9ec7853abf..5baaa2ba98 100644 --- a/var/spack/repos/builtin/packages/cbtf-krell/package.py +++ b/var/spack/repos/builtin/packages/cbtf-krell/package.py @@ -193,7 +193,7 @@ 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. - store = spack.store.store() + store = spack.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') diff --git a/var/spack/repos/builtin/packages/openspeedshop/package.py b/var/spack/repos/builtin/packages/openspeedshop/package.py index 2663a3ff33..dd9e8e8503 100644 --- a/var/spack/repos/builtin/packages/openspeedshop/package.py +++ b/var/spack/repos/builtin/packages/openspeedshop/package.py @@ -197,7 +197,7 @@ 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. - store = spack.store.store() + store = spack.store be_ck = store.db.query_one('cbtf-krell arch=cray-CNL-haswell') # Equivalent to install-tool cmake arg: diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py index 192e31f32f..1759c15d86 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.store().extensions) + spack.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.store().extensions) + spack.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 b2ca9a29b4..34e1e0ea6d 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.store().layout.metadata_path(self.spec), + spack.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.store().layout.metadata_path(self.spec), + spack.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.store().extensions) + spack.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.store().extensions) + spack.store.extensions) exts = extensions_layout.extension_map(self.spec) # Make deactivate idempotent |