summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2018-05-17 11:43:23 -0700
committerscheibelp <scheibel1@llnl.gov>2018-05-17 14:10:30 -0700
commit5ef30e0a51abf8886e28a8561998c09aa89e8083 (patch)
tree618bbeb403a83a5615da9c98fe82278c8a3e4dc7
parente9a3e3bfbb17bc42073be0c5e6d7b9efc476d9f7 (diff)
downloadspack-5ef30e0a51abf8886e28a8561998c09aa89e8083.tar.gz
spack-5ef30e0a51abf8886e28a8561998c09aa89e8083.tar.bz2
spack-5ef30e0a51abf8886e28a8561998c09aa89e8083.tar.xz
spack-5ef30e0a51abf8886e28a8561998c09aa89e8083.zip
make check_for_compiler_existence an instance variable
-rw-r--r--lib/spack/spack/cmd/mirror.py2
-rw-r--r--lib/spack/spack/concretize.py30
-rw-r--r--lib/spack/spack/test/concretize.py2
3 files changed, 16 insertions, 18 deletions
diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py
index 42703fd232..9780611227 100644
--- a/lib/spack/spack/cmd/mirror.py
+++ b/lib/spack/spack/cmd/mirror.py
@@ -169,7 +169,7 @@ def mirror_create(args):
"""Create a directory to be used as a spack mirror, and fill it with
package archives."""
# try to parse specs from the command line first.
- with spack.concretize.disable_compiler_existence_check():
+ with spack.concretize.concretizer.disable_compiler_existence_check():
specs = spack.cmd.parse_specs(args.specs, concretize=True)
# If there is a file, parse each line as a spec and add it to the list.
diff --git a/lib/spack/spack/concretize.py b/lib/spack/spack/concretize.py
index 2f57cb7504..58aca31a1f 100644
--- a/lib/spack/spack/concretize.py
+++ b/lib/spack/spack/concretize.py
@@ -50,10 +50,6 @@ import spack.error
from spack.version import ver, Version, VersionList, VersionRange
from spack.package_prefs import PackagePrefs, spec_externals, is_spec_buildable
-#: controls whether we check that compiler versions actually exist during
-#: concretization. Used for testing.
-check_for_compiler_existence = True
-
#: Concretizer singleton
concretizer = llnl.util.lang.Singleton(lambda: Concretizer())
@@ -63,19 +59,21 @@ concretizer = llnl.util.lang.Singleton(lambda: Concretizer())
_abi = llnl.util.lang.Singleton(lambda: spack.abi.ABI())
-@contextmanager
-def disable_compiler_existence_check():
- global check_for_compiler_existence
- saved = check_for_compiler_existence
- check_for_compiler_existence = False
- yield
- check_for_compiler_existence = saved
-
-
class Concretizer(object):
"""You can subclass this class to override some of the default
concretization strategies, or you can override all of them.
"""
+ def __init__(self):
+ # controls whether we check that compiler versions actually exist
+ # during concretization. Used for testing and for mirror creation
+ self.check_for_compiler_existence = True
+
+ @contextmanager
+ def disable_compiler_existence_check(self):
+ saved = self.check_for_compiler_existence
+ self.check_for_compiler_existence = False
+ yield
+ self.check_for_compiler_existence = saved
def _valid_virtuals_and_externals(self, spec):
"""Returns a list of candidate virtual dep providers and external
@@ -311,7 +309,7 @@ class Concretizer(object):
return spack.compilers.compilers_for_spec(cspec, arch_spec=aspec)
if spec.compiler and spec.compiler.concrete:
- if (check_for_compiler_existence and not
+ if (self.check_for_compiler_existence and not
_proper_compiler_style(spec.compiler, spec.architecture)):
_compiler_concretization_failure(
spec.compiler, spec.architecture)
@@ -325,7 +323,7 @@ class Concretizer(object):
# Check if the compiler is already fully specified
if (other_compiler and other_compiler.concrete and
- not check_for_compiler_existence):
+ not self.check_for_compiler_existence):
spec.compiler = other_compiler.copy()
return True
@@ -419,7 +417,7 @@ class Concretizer(object):
compiler = spack.compilers.compiler_for_spec(
spec.compiler, spec.architecture)
except spack.compilers.NoCompilerForSpecError:
- if check_for_compiler_existence:
+ if self.check_for_compiler_existence:
raise
return ret
for flag in compiler.flags:
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index 028bc23583..a90b355d84 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -153,7 +153,7 @@ class TestConcretize(object):
with pytest.raises(spack.concretize.UnavailableCompilerVersionError):
check_concretize('dttop %gcc@100.100')
- with spack.concretize.disable_compiler_existence_check():
+ with spack.concretize.concretizer.disable_compiler_existence_check():
spec = check_concretize('dttop %gcc@100.100')
assert spec.satisfies('%gcc@100.100')
assert spec['dtlink3'].satisfies('%gcc@100.100')