From 1307ad3979498916011df47121bba1020da9f2e8 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 11 Apr 2018 21:50:03 +0200 Subject: Package.provides account for v deps that are provided conditionally (#7716) fixes #7705 Package.provides now checks constraints to ensure that a spec provides a given virtual package. Note that 'strict=True' is not passed to satisfies as this function is also used during concretization. --- lib/spack/spack/package.py | 5 ++++- lib/spack/spack/test/concretize.py | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 3dc99e1cef..9117cbbaea 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -949,7 +949,10 @@ class PackageBase(with_metaclass(PackageMeta, object)): """ 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 0478d5233b..13dd490d24 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -515,3 +515,12 @@ class TestConcretize(object): # 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') -- cgit v1.2.3-70-g09d2