From 3b12a8b192b7438c06e2a10eb0d15275b9ef225d Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Wed, 30 Mar 2022 05:19:52 -0700 Subject: patch cache: fix bug finding inherited packages (#29574) --- lib/spack/spack/package.py | 19 +++++++++++++++++++ lib/spack/spack/patch.py | 8 ++++++-- 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 @@ -373,6 +373,21 @@ class PackageMeta( """Name of this package, including the namespace""" 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. @@ -863,6 +878,10 @@ class PackageBase(six.with_metaclass(PackageMeta, PackageViewMixin, object)): """Name of this package, including namespace: namespace.name.""" 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).""" 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)) -- cgit v1.2.3-70-g09d2