spack.repo.get() can only be called on concrete specs (#31411)
The goal of this PR is to make clearer where we need a package object in Spack as opposed to a package class. We currently instantiate a lot of package objects when we could make do with a class. We should use the class when we only need metadata, and we should only instantiate and us an instance of `PackageBase` at build time. Modifications: - [x] Remove the `spack.repo.get` convenience function (which was used in many places, and not really needed) - [x] Use `spack.repo.path.get_pkg_class` wherever possible - [x] Try to route most of the need for `spack.repo.path.get` through `Spec.package` - [x] Introduce a non-data descriptor, that can be used as a decorator, to have "class level properties" - [x] Refactor unit tests that had to be modified to reduce code duplication - [x] `Spec.package` and `Repo.get` now require a concrete spec as input - [x] Remove `RepoPath.all_packages` and `Repo.all_packages`
This commit is contained in:
committed by
GitHub
parent
6ceb274de0
commit
7f2b5e8e57
@@ -19,6 +19,16 @@ class Multimethod(MultimethodBase):
|
||||
homepage = 'http://www.example.com/'
|
||||
url = 'http://www.example.com/example-1.0.tar.gz'
|
||||
|
||||
version('5.0', '0123456789abcdef0123456789abcdef')
|
||||
version('4.0', '0123456789abcdef0123456789abcdef')
|
||||
version('3.0', '0123456789abcdef0123456789abcdef')
|
||||
version('2.0', '0123456789abcdef0123456789abcdef')
|
||||
version('1.0', '0123456789abcdef0123456789abcdef')
|
||||
|
||||
variant('mpi', default=False, description='')
|
||||
|
||||
depends_on('mpi', when='+mpi')
|
||||
|
||||
#
|
||||
# These functions are only valid for versions 1, 3, and 4.
|
||||
#
|
||||
@@ -76,9 +86,9 @@ def has_a_default(self):
|
||||
def has_a_default(self):
|
||||
return 'gcc'
|
||||
|
||||
@when('%intel')
|
||||
@when('%clang')
|
||||
def has_a_default(self):
|
||||
return 'intel'
|
||||
return 'clang'
|
||||
|
||||
#
|
||||
# Make sure we can switch methods on different target
|
||||
|
||||
Reference in New Issue
Block a user