X Tutup
Skip to content

Commit 6786397

Browse files
tgamblinscheibelp
authored andcommitted
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
1 parent 3e6d85c commit 6786397

File tree

2 files changed

+21
-26
lines changed

2 files changed

+21
-26
lines changed

lib/spack/spack/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@
2525
##############################################################################
2626
import sys
2727

28-
#-----------------------------------------------------------------------------
29-
# Below code imports spack packages.
30-
#-----------------------------------------------------------------------------
31-
# The imports depend on paths above, or on each other, so ordering is tricky.
32-
# TODO: refactor everything below to be more init order agnostic.
33-
34-
35-
# TODO: get this out of __init__.py
36-
binary_cache_retrieved_specs = set()
37-
38-
3928
#-----------------------------------------------------------------------------
4029
# Initialize various data structures & objects at the core of Spack.
4130
#

lib/spack/spack/binary_distribution.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,26 @@
2626
import os
2727
import re
2828
import tarfile
29-
import yaml
3029
import shutil
3130
import platform
3231
import tempfile
32+
import hashlib
33+
from contextlib import closing
34+
35+
import yaml
3336

3437
import llnl.util.tty as tty
35-
from spack.util.gpg import Gpg
3638
from llnl.util.filesystem import mkdirp, join_path, install_tree
37-
from spack.util.web import spider
38-
import spack.cmd
39+
3940
import spack
40-
from spack.stage import Stage
41+
import spack.cmd
4142
import spack.fetch_strategy as fs
42-
from contextlib import closing
4343
import spack.util.gpg as gpg_util
44-
import hashlib
45-
from spack.util.executable import ProcessError
4644
import spack.relocate as relocate
45+
from spack.stage import Stage
46+
from spack.util.gpg import Gpg
47+
from spack.util.web import spider
48+
from spack.util.executable import ProcessError
4749

4850

4951
class NoOverwriteException(Exception):
@@ -529,14 +531,19 @@ def extract_tarball(spec, filename, allow_root=False, unsigned=False,
529531
shutil.rmtree(tmpdir)
530532

531533

534+
#: Internal cache for get_specs
535+
_cached_specs = None
536+
537+
532538
def get_specs(force=False):
533539
"""
534540
Get spec.yaml's for build caches available on mirror
535541
"""
536-
if spack.binary_cache_retrieved_specs:
542+
global _cached_specs
543+
544+
if _cached_specs:
537545
tty.debug("Using previously-retrieved specs")
538-
previously_retrieved = spack.binary_cache_retrieved_specs
539-
return previously_retrieved
546+
return _cached_specs
540547

541548
mirrors = spack.config.get('mirrors')
542549
if len(mirrors) == 0:
@@ -562,7 +569,7 @@ def get_specs(force=False):
562569
if re.search("spec.yaml", link) and re.search(path, link):
563570
urls.add(link)
564571

565-
specs = set()
572+
_cached_specs = set()
566573
for link in urls:
567574
with Stage(link, name="build_cache", keep=True) as stage:
568575
if force and os.path.exists(stage.save_filename):
@@ -578,10 +585,9 @@ def get_specs(force=False):
578585
# we need to mark this spec concrete on read-in.
579586
spec = spack.spec.Spec.from_yaml(f)
580587
spec._mark_concrete()
581-
specs.add(spec)
588+
_cached_specs.add(spec)
582589

583-
spack.binary_cache_retrieved_specs = specs
584-
return specs
590+
return _cached_specs
585591

586592

587593
def get_keys(install=False, trust=False, force=False):

0 commit comments

Comments
 (0)
X Tutup