summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2022-04-27 10:10:46 +0200
committerGitHub <noreply@github.com>2022-04-27 02:10:46 -0600
commitd5fc859f46627f55ff178d1ce9a0f6fe8b42d4c6 (patch)
tree3afbcebc40b2cc67f7434711fc24d23d352ffd87
parent753f4a4bc3b2ed99c6fc78bbe33cd407f8fe0fa3 (diff)
downloadspack-d5fc859f46627f55ff178d1ce9a0f6fe8b42d4c6.tar.gz
spack-d5fc859f46627f55ff178d1ce9a0f6fe8b42d4c6.tar.bz2
spack-d5fc859f46627f55ff178d1ce9a0f6fe8b42d4c6.tar.xz
spack-d5fc859f46627f55ff178d1ce9a0f6fe8b42d4c6.zip
ASP-based solver: handle installed specs from unknown namespaces (#30092)
fixes #28259 This commit discard specs from unknown namespaces from the ones that can be "reused" during concretization. Previously Spack would just error out when encountering them.
-rw-r--r--lib/spack/spack/solver/asp.py6
-rw-r--r--lib/spack/spack/test/concretize.py38
2 files changed, 44 insertions, 0 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 7b082382db..6ec041e89b 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -1659,6 +1659,12 @@ class SpackSolverSetup(object):
# be dependencies (don't tell it about the others)
h = spec.dag_hash()
if spec.name in possible and h not in self.seen_hashes:
+ try:
+ # Only consider installed packages for repo we know
+ spack.repo.path.repo_for_pkg(spec)
+ except spack.repo.UnknownNamespaceError:
+ return
+
# this indicates that there is a spec like this installed
self.gen.fact(fn.installed_hash(spec.name, h))
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index 32b94257bc..984f3e9b01 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -204,6 +204,28 @@ class Changing(Package):
return _changing_pkg
+@pytest.fixture()
+def additional_repo_with_c(tmpdir_factory, mutable_mock_repo):
+ """Add a repository with a simple package"""
+ repo_dir = tmpdir_factory.mktemp('myrepo')
+ repo_dir.join('repo.yaml').write("""
+repo:
+ namespace: myrepo
+""", ensure=True)
+ packages_dir = repo_dir.ensure('packages', dir=True)
+ package_py = """
+class C(Package):
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/root-1.0.tar.gz"
+
+ version(1.0, sha256='abcde')
+"""
+ packages_dir.join('c', 'package.py').write(package_py, ensure=True)
+ repo = spack.repo.Repo(str(repo_dir))
+ mutable_mock_repo.put_first(repo)
+ return repo
+
+
# This must use the mutable_config fixture because the test
# adjusting_default_target_based_on_compiler uses the current_host fixture,
# which changes the config.
@@ -1607,3 +1629,19 @@ class TestConcretize(object):
new_root = Spec('root').concretized()
assert not new_root['changing'].satisfies('@1.0')
+
+ @pytest.mark.regression('28259')
+ def test_reuse_with_unknown_namespace_dont_raise(
+ self, additional_repo_with_c, mutable_mock_repo
+ ):
+ s = Spec('c').concretized()
+ assert s.namespace == 'myrepo'
+ s.package.do_install(fake=True, explicit=True)
+
+ # TODO: To mock repo removal we need to recreate the RepoPath
+ mutable_mock_repo.remove(additional_repo_with_c)
+ spack.repo.path = spack.repo.RepoPath(*spack.repo.path.repos)
+
+ with spack.config.override("concretizer:reuse", True):
+ s = Spec('c').concretized()
+ assert s.namespace == 'builtin.mock'