diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2020-11-11 19:21:27 +0100 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2020-11-17 10:04:13 -0800 |
commit | 9a03fd2834b29920ee0c11060dc928f368863606 (patch) | |
tree | e0a0f35776978b6bf46b23cb471d211543879672 /lib | |
parent | 44aa94a210e8189a452030afd0627d9e3faac9d1 (diff) | |
download | spack-9a03fd2834b29920ee0c11060dc928f368863606.tar.gz spack-9a03fd2834b29920ee0c11060dc928f368863606.tar.bz2 spack-9a03fd2834b29920ee0c11060dc928f368863606.tar.xz spack-9a03fd2834b29920ee0c11060dc928f368863606.zip |
concretizer: don't require a provider for virtual deps if spec is external
This commit introduces a new rule:
real_node(Package) :- not external(Package), node(Package).
that permits to distinguish between an external node and a
real node that shouldn't trim dependency. It solves the
case of concretizing ninja with an external Python.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/solver/asp.py | 6 | ||||
-rw-r--r-- | lib/spack/spack/solver/concretize.lp | 3 | ||||
-rw-r--r-- | lib/spack/spack/test/concretize.py | 6 | ||||
-rw-r--r-- | lib/spack/spack/test/data/config/packages.yaml | 5 |
4 files changed, 17 insertions, 3 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 1f314b8f52..f0f2b410e8 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -938,13 +938,13 @@ class SpackSolverSetup(object): # add constraints on the dependency from dep spec. if spack.repo.path.is_virtual(dep.spec.name): self.virtual_constraints.add(str(dep.spec)) + conditions = ([fn.real_node(pkg.name)] + + self.spec_clauses(named_cond, body=True)) self.gen.rule( head=fn.single_provider_for( str(dep.spec.name), str(dep.spec.versions) ), - body=self.gen._and( - *self.spec_clauses(named_cond, body=True) - ) + body=self.gen._and(*conditions) ) else: clauses = self.spec_clauses(dep.spec) diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index 9f8ab81161..d6d6c835ca 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -144,6 +144,9 @@ version_declared(Package, Version, Weight) :- external_version_declared(Package, % if a package is not buildable (external_only), only externals are allowed external(Package) :- external_only(Package), node(Package). +% a package is a real_node if it is not external +real_node(Package) :- node(Package), not external(Package). + % if an external version is selected, the package is external and % we are using the corresponding spec external(Package) :- diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 6275954df0..496153aab6 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -866,3 +866,9 @@ class TestConcretize(object): assert s.dag_hash() == t.dag_hash() assert s.build_hash() == t.build_hash() assert s.full_hash() == t.full_hash() + + def test_external_that_would_require_a_virtual_dependency(self): + s = Spec('requires-virtual').concretized() + + assert s.external + assert 'stuff' not in s diff --git a/lib/spack/spack/test/data/config/packages.yaml b/lib/spack/spack/test/data/config/packages.yaml index c2e8d558b3..748a46b1a1 100644 --- a/lib/spack/spack/test/data/config/packages.yaml +++ b/lib/spack/spack/test/data/config/packages.yaml @@ -22,3 +22,8 @@ packages: - spec: externalmodule@1.0%gcc@4.5.0 modules: - external-module + 'requires-virtual': + buildable: False + externals: + - spec: requires-virtual@2.0 + prefix: /usr |