From 58a32b04d90da7d2edc4388e78feb84abe8fb089 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(-) (limited to 'lib') diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index e200985cdd..edd00caae6 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -400,6 +400,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. @@ -911,6 +926,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 4485313053..33f9fa57eb 100644 --- a/lib/spack/spack/patch.py +++ b/lib/spack/spack/patch.py @@ -368,8 +368,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-60-g2f50