From e79a911bacafd68a24a6ff8519293375cae45a7d Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Tue, 18 Apr 2023 09:49:50 -0700 Subject: 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. --- lib/spack/spack/solver/asp.py | 24 +++++++++++++++++++----- 1 file 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. -- cgit v1.2.3-70-g09d2