summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2023-04-18 09:49:50 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2023-05-15 09:15:49 -0700
commite79a911bacafd68a24a6ff8519293375cae45a7d (patch)
treeb95e242c70ba3062ed92925f0fe50134e721cb93 /lib
parentfd3efc71fd3c97a9b83bd0b44d706a32049d3fc0 (diff)
downloadspack-e79a911bacafd68a24a6ff8519293375cae45a7d.tar.gz
spack-e79a911bacafd68a24a6ff8519293375cae45a7d.tar.bz2
spack-e79a911bacafd68a24a6ff8519293375cae45a7d.tar.xz
spack-e79a911bacafd68a24a6ff8519293375cae45a7d.zip
bugfix: allow reuse of packages from foreign namespaces
We currently throw a nasty error if you try to reuse packages from some other namespace (e.g., OLCF), but we should be able to reuse patched local versions of builtin packages. Right now the only obstacle to that is that we try to look up virtual info for unknown namespaces, and we can't get the package from the repo to do that. We *can* assume that a package with a known namespace is similar, and that its virtual provider information is reasonably accurate, so we now do that. This isn't 100% accurate, but neither is relying on the package itself, as it may have gone out of date. The real solution here is virtual edge information, but this is a stopgap until we have that.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/asp.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index a4decb4b12..220d3440ae 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -1669,13 +1669,27 @@ class SpackSolverSetup(object):
if concrete_build_deps or dtype != "build":
clauses.append(fn.attr("depends_on", spec.name, dep.name, dtype))
- # Skip virtual node constriants for renamed/deleted packages,
- # so their binaries can still be installed.
- # NOTE: with current specs (which lack edge attributes) this
- # can allow concretizations with two providers, but it's unlikely.
+ # TODO: We have to look up info from package.py here, but we'd
+ # TODO: like to avoid this entirely. We should not need to look
+ # TODO: up potentially wrong info if we have virtual edge info.
try:
- virtuals = dep.package.virtuals_provided
+ try:
+ pkg = dep.package
+
+ except spack.repo.UnknownNamespaceError:
+ # Try to look up the package of the same name and use its
+ # providers. This is as good as we can do without edge info.
+ pkg_class = spack.repo.path.get_pkg_class(dep.name)
+ spec = spack.spec.Spec(f"{dep.name}@{dep.version}")
+ pkg = pkg_class(spec)
+
+ virtuals = pkg.virtuals_provided
+
except spack.repo.UnknownPackageError:
+ # Skip virtual node constriants for renamed/deleted packages,
+ # so their binaries can still be installed.
+ # NOTE: with current specs (which lack edge attributes) this
+ # can allow concretizations with two providers, but it's unlikely.
continue
# Don't concretize with two providers of the same virtual.