diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 3dc99e1cef5..9117cbbaeab 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -949,7 +949,10 @@ def provides(self, vpkg_name): """ True if this package provides a virtual package with the specified name """ - return any(s.name == vpkg_name for s in self.provided) + return any( + any(self.spec.satisfies(c) for c in constraints) + for s, constraints in self.provided.items() if s.name == vpkg_name + ) @property def installed(self): diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 0478d5233bc..13dd490d244 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -515,3 +515,12 @@ def test_regression_issue_7239(self): # Mimics asking the build interface from a build interface build_interface = s['mpileaks']['mpileaks'] assert llnl.util.lang.ObjectWrapper in type(build_interface).__mro__ + + @pytest.mark.regression('7705') + def test_regression_issue_7705(self): + # spec.package.provides(name) doesn't account for conditional + # constraints in the concretized spec + s = Spec('simple-inheritance~openblas') + s.concretize() + + assert not s.package.provides('lapack')