diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2018-04-26 15:31:37 -0700 |
---|---|---|
committer | scheibelp <scheibel1@llnl.gov> | 2018-05-17 14:10:30 -0700 |
commit | 678639749c447ba79cea9dfd731bdfd40f9f5dac (patch) | |
tree | d133b8f4de5aff189d9e03e3cfa24bca327d8375 | |
parent | 3e6d85c404939482cfee140b272e6dfc6b333540 (diff) | |
download | spack-678639749c447ba79cea9dfd731bdfd40f9f5dac.tar.gz spack-678639749c447ba79cea9dfd731bdfd40f9f5dac.tar.bz2 spack-678639749c447ba79cea9dfd731bdfd40f9f5dac.tar.xz spack-678639749c447ba79cea9dfd731bdfd40f9f5dac.zip |
init: remove binary_cache_retrieved_specs global variable
- remove variable from spack/__init__.py
- clean up imports and some code structure in binary_distribution.py
-rw-r--r-- | lib/spack/spack/__init__.py | 11 | ||||
-rw-r--r-- | lib/spack/spack/binary_distribution.py | 36 |
2 files changed, 21 insertions, 26 deletions
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py index 2467596a34..714f0e7377 100644 --- a/lib/spack/spack/__init__.py +++ b/lib/spack/spack/__init__.py @@ -26,17 +26,6 @@ import sys #----------------------------------------------------------------------------- -# Below code imports spack packages. -#----------------------------------------------------------------------------- -# The imports depend on paths above, or on each other, so ordering is tricky. -# TODO: refactor everything below to be more init order agnostic. - - -# TODO: get this out of __init__.py -binary_cache_retrieved_specs = set() - - -#----------------------------------------------------------------------------- # Initialize various data structures & objects at the core of Spack. # # TODO: move all of these imports out of __init__ to avoid importing the whole diff --git a/lib/spack/spack/binary_distribution.py b/lib/spack/spack/binary_distribution.py index fe0924fddb..2a0dd7633d 100644 --- a/lib/spack/spack/binary_distribution.py +++ b/lib/spack/spack/binary_distribution.py @@ -26,24 +26,26 @@ import os import re import tarfile -import yaml import shutil import platform import tempfile +import hashlib +from contextlib import closing + +import yaml import llnl.util.tty as tty -from spack.util.gpg import Gpg from llnl.util.filesystem import mkdirp, join_path, install_tree -from spack.util.web import spider -import spack.cmd + import spack -from spack.stage import Stage +import spack.cmd import spack.fetch_strategy as fs -from contextlib import closing import spack.util.gpg as gpg_util -import hashlib -from spack.util.executable import ProcessError import spack.relocate as relocate +from spack.stage import Stage +from spack.util.gpg import Gpg +from spack.util.web import spider +from spack.util.executable import ProcessError class NoOverwriteException(Exception): @@ -529,14 +531,19 @@ def extract_tarball(spec, filename, allow_root=False, unsigned=False, shutil.rmtree(tmpdir) +#: Internal cache for get_specs +_cached_specs = None + + def get_specs(force=False): """ Get spec.yaml's for build caches available on mirror """ - if spack.binary_cache_retrieved_specs: + global _cached_specs + + if _cached_specs: tty.debug("Using previously-retrieved specs") - previously_retrieved = spack.binary_cache_retrieved_specs - return previously_retrieved + return _cached_specs mirrors = spack.config.get('mirrors') if len(mirrors) == 0: @@ -562,7 +569,7 @@ def get_specs(force=False): if re.search("spec.yaml", link) and re.search(path, link): urls.add(link) - specs = set() + _cached_specs = set() for link in urls: with Stage(link, name="build_cache", keep=True) as stage: if force and os.path.exists(stage.save_filename): @@ -578,10 +585,9 @@ def get_specs(force=False): # we need to mark this spec concrete on read-in. spec = spack.spec.Spec.from_yaml(f) spec._mark_concrete() - specs.add(spec) + _cached_specs.add(spec) - spack.binary_cache_retrieved_specs = specs - return specs + return _cached_specs def get_keys(install=False, trust=False, force=False): |