concretize: fix UnboundLocalError due to import within a function (#16809)

This commit is contained in:
Sergey Kosukhin 2020-05-27 11:45:14 +02:00 committed by Gregory Becker
parent dc59fc7ab8
commit e2f5f668a9
2 changed files with 7 additions and 1 deletions

View File

@ -2134,6 +2134,8 @@ def concretize(self, tests=False):
consistent with requirements of its packages. See flatten() and
normalize() for more details on this.
"""
import spack.concretize
if not self.name:
raise spack.error.SpecError(
"Attempting to concretize anonymous spec")
@ -2145,7 +2147,6 @@ def concretize(self, tests=False):
force = False
user_spec_deps = self.flat_dependencies(copy=False)
import spack.concretize
concretizer = spack.concretize.Concretizer(self.copy())
while changed:
changes = (self.normalize(force, tests=tests,

View File

@ -633,3 +633,8 @@ def test_compiler_version_matches_any_entry_in_compilers_yaml(self):
s = Spec('mpileaks %gcc@4.5:')
s.concretize()
assert str(s.compiler.version) == '4.5.0'
def test_concretize_anonymous(self):
with pytest.raises(spack.error.SpecError):
s = Spec('+variant')
s.concretize()