summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2022-03-30 05:19:52 -0700
committerMassimiliano Culpo <massimiliano.culpo@gmail.com>2022-04-14 11:08:17 +0200
commit3b12a8b192b7438c06e2a10eb0d15275b9ef225d (patch)
tree1c00d97e43ff71d5726a87afca3d9292630cf9e7
parente9896620e4cc4dfb2c736940ee303c7fce11001e (diff)
downloadspack-3b12a8b192b7438c06e2a10eb0d15275b9ef225d.tar.gz
spack-3b12a8b192b7438c06e2a10eb0d15275b9ef225d.tar.bz2
spack-3b12a8b192b7438c06e2a10eb0d15275b9ef225d.tar.xz
spack-3b12a8b192b7438c06e2a10eb0d15275b9ef225d.zip
patch cache: fix bug finding inherited packages (#29574)
-rw-r--r--lib/spack/spack/package.py19
-rw-r--r--lib/spack/spack/patch.py8
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 453623d97a..69d2de41b7 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -374,6 +374,21 @@ class PackageMeta(
return '%s.%s' % (self.namespace, self.name)
@property
+ def fullnames(self):
+ """
+ Fullnames for this package and any packages from which it inherits.
+ """
+ fullnames = []
+ for cls in inspect.getmro(self):
+ namespace = getattr(cls, 'namespace', None)
+ if namespace:
+ fullnames.append('%s.%s' % (namespace, self.name))
+ if namespace == 'builtin':
+ # builtin packages cannot inherit from other repos
+ break
+ return fullnames
+
+ @property
def name(self):
"""The name of this package.
@@ -864,6 +879,10 @@ class PackageBase(six.with_metaclass(PackageMeta, PackageViewMixin, object)):
return type(self).fullname
@property
+ def fullnames(self):
+ return type(self).fullnames
+
+ @property
def name(self):
"""Name of this package (the module without parent modules)."""
return type(self).name
diff --git a/lib/spack/spack/patch.py b/lib/spack/spack/patch.py
index a273514636..5bfd7722d6 100644
--- a/lib/spack/spack/patch.py
+++ b/lib/spack/spack/patch.py
@@ -348,8 +348,12 @@ class PatchCache(object):
"Couldn't find patch for package %s with sha256: %s"
% (pkg.fullname, sha256))
- patch_dict = sha_index.get(pkg.fullname)
- if not patch_dict:
+ # Find patches for this class or any class it inherits from
+ for fullname in pkg.fullnames:
+ patch_dict = sha_index.get(fullname)
+ if patch_dict:
+ break
+ else:
raise NoSuchPatchError(
"Couldn't find patch for package %s with sha256: %s"
% (pkg.fullname, sha256))