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.
This commit is contained in:
		 Massimiliano Culpo
					Massimiliano Culpo
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							753f4a4bc3
						
					
				
				
					commit
					d5fc859f46
				
			| @@ -1659,6 +1659,12 @@ def _facts_from_concrete_spec(self, spec, possible): | |||||||
|         # be dependencies (don't tell it about the others) |         # be dependencies (don't tell it about the others) | ||||||
|         h = spec.dag_hash() |         h = spec.dag_hash() | ||||||
|         if spec.name in possible and h not in self.seen_hashes: |         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 |             # this indicates that there is a spec like this installed | ||||||
|             self.gen.fact(fn.installed_hash(spec.name, h)) |             self.gen.fact(fn.installed_hash(spec.name, h)) | ||||||
| 
 | 
 | ||||||
|   | |||||||
| @@ -204,6 +204,28 @@ def change(self, changes=None): | |||||||
|     return _changing_pkg |     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 | # This must use the mutable_config fixture because the test | ||||||
| # adjusting_default_target_based_on_compiler uses the current_host fixture, | # adjusting_default_target_based_on_compiler uses the current_host fixture, | ||||||
| # which changes the config. | # which changes the config. | ||||||
| @@ -1607,3 +1629,19 @@ def test_installed_version_is_selected_only_for_reuse( | |||||||
|             new_root = Spec('root').concretized() |             new_root = Spec('root').concretized() | ||||||
| 
 | 
 | ||||||
|         assert not new_root['changing'].satisfies('@1.0') |         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' | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user