2626import os
2727import re
2828import tarfile
29- import yaml
3029import shutil
3130import platform
3231import tempfile
32+ import hashlib
33+ from contextlib import closing
34+
35+ import yaml
3336
3437import llnl .util .tty as tty
35- from spack .util .gpg import Gpg
3638from llnl .util .filesystem import mkdirp , join_path , install_tree
37- from spack .util .web import spider
38- import spack .cmd
39+
3940import spack
40- from spack .stage import Stage
41+ import spack .cmd
4142import spack .fetch_strategy as fs
42- from contextlib import closing
4343import spack .util .gpg as gpg_util
44- import hashlib
45- from spack .util .executable import ProcessError
4644import 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
4951class 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+
532538def 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
587593def get_keys (install = False , trust = False , force = False ):
0 commit comments