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 GitHub
parent d8c7073a9f
commit e73c39a5db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 consistent with requirements of its packages. See flatten() and
normalize() for more details on this. normalize() for more details on this.
""" """
import spack.concretize
if not self.name: if not self.name:
raise spack.error.SpecError( raise spack.error.SpecError(
"Attempting to concretize anonymous spec") "Attempting to concretize anonymous spec")
@ -2145,7 +2147,6 @@ def concretize(self, tests=False):
force = False force = False
user_spec_deps = self.flat_dependencies(copy=False) user_spec_deps = self.flat_dependencies(copy=False)
import spack.concretize
concretizer = spack.concretize.Concretizer(self.copy()) concretizer = spack.concretize.Concretizer(self.copy())
while changed: while changed:
changes = (self.normalize(force, tests=tests, 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 = Spec('mpileaks %gcc@4.5:')
s.concretize() s.concretize()
assert str(s.compiler.version) == '4.5.0' assert str(s.compiler.version) == '4.5.0'
def test_concretize_anonymous(self):
with pytest.raises(spack.error.SpecError):
s = Spec('+variant')
s.concretize()