From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1567958-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 47732158089
	for <garchives@archives.gentoo.org>; Sun,  5 Nov 2023 13:46:13 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 801432BC013;
	Sun,  5 Nov 2023 13:46:12 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 633DC2BC013
	for <gentoo-commits@lists.gentoo.org>; Sun,  5 Nov 2023 13:46:12 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 6070B335CCD
	for <gentoo-commits@lists.gentoo.org>; Sun,  5 Nov 2023 13:46:11 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id AE226129E
	for <gentoo-commits@lists.gentoo.org>; Sun,  5 Nov 2023 13:46:09 +0000 (UTC)
From: "Ulrich Müller" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" <ulm@gentoo.org>
Message-ID: <1699191942.876398edc86a7c72569a36b3f972219a9c34a11d.ulm@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: www-apps/nikola/files/, www-apps/nikola/
X-VCS-Repository: repo/gentoo
X-VCS-Files: www-apps/nikola/files/nikola-8.2.4-yapsy.patch www-apps/nikola/nikola-8.2.4.ebuild
X-VCS-Directories: www-apps/nikola/ www-apps/nikola/files/
X-VCS-Committer: ulm
X-VCS-Committer-Name: Ulrich Müller
X-VCS-Revision: 876398edc86a7c72569a36b3f972219a9c34a11d
X-VCS-Branch: master
Date: Sun,  5 Nov 2023 13:46:09 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: a8f27f49-b116-41b7-b466-cd63633d8c05
X-Archives-Hash: 04ab057ae671e2c58b2a3066e6657d04

commit:     876398edc86a7c72569a36b3f972219a9c34a11d
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  5 13:43:10 2023 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Nov  5 13:45:42 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=876398ed

www-apps/nikola: Fix loading of plugins

Bug: https://bugs.gentoo.org/916872
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 www-apps/nikola/files/nikola-8.2.4-yapsy.patch | 45 ++++++++++++++++++++++++++
 www-apps/nikola/nikola-8.2.4.ebuild            |  2 ++
 2 files changed, 47 insertions(+)

diff --git a/www-apps/nikola/files/nikola-8.2.4-yapsy.patch b/www-apps/nikola/files/nikola-8.2.4-yapsy.patch
new file mode 100644
index 000000000000..563b92609879
--- /dev/null
+++ b/www-apps/nikola/files/nikola-8.2.4-yapsy.patch
@@ -0,0 +1,45 @@
+https://bugs.gentoo.org/916872
+https://github.com/getnikola/nikola/issues/3700
+Patch from upstream.
+
+commit 4f51e2e0a0b1c0de375d15d06cfacd703ab03040
+Author: Adam Williamson <awilliam@redhat.com>
+Date:   Sat, 15 Jul 2023 09:34:30 -0700
+
+    Handle change to plugin loading in recent yapsy (#3700) (#3701)
+
+--- a/nikola/plugin_categories.py
++++ b/nikola/plugin_categories.py
+@@ -75,8 +75,31 @@ def set_site(self, site):
+     def inject_templates(self):
+         """Inject 'templates/<engine>' (if exists) very early in the theme chain."""
+         try:
++            mod_candidate = None
++            # since https://github.com/tibonihoo/yapsy/pull/11 ,
++            # yapsy only adds each imported plugin to sys.modules
++            # under its modified, "unique" name (see early in
++            # PluginManager.loadPlugins), so we recreate the
++            # modified name here to find it. we fudge the serial
++            # number here, assuming that if a plugin is loaded
++            # under the same name multiple times, the location
++            # will also be the same, so we can just use 0.
++            possible_names = (
++                self.__class__.__module__,
++                "yapsy_loaded_plugin_" + self.__class__.__module__ + "_0",
++                "yapsy_loaded_plugin_" + self.name + "_0",
++            )
++            for possible_name in possible_names:
++                mod_candidate = sys.modules.get(possible_name)
++                if mod_candidate:
++                    break
++            if not mod_candidate:
++                # well, we tried. we wind up here for the dummy
++                # plugins; honestly I'm not sure exactly why/how,
++                # but they don't have templates, so it's okay
++                return
+             # Sorry, found no other way to get this
+-            mod_path = sys.modules[self.__class__.__module__].__file__
++            mod_path = mod_candidate.__file__
+             mod_dir = os.path.dirname(mod_path)
+             tmpl_dir = os.path.join(
+                 mod_dir, 'templates', self.site.template_system.name

diff --git a/www-apps/nikola/nikola-8.2.4.ebuild b/www-apps/nikola/nikola-8.2.4.ebuild
index 93ffb6d32eea..76917982b3b4 100644
--- a/www-apps/nikola/nikola-8.2.4.ebuild
+++ b/www-apps/nikola/nikola-8.2.4.ebuild
@@ -37,6 +37,8 @@ RDEPEND="${BDEPEND}
 	dev-python/pillow[jpeg,${PYTHON_USEDEP}]
 	dev-python/cloudpickle[${PYTHON_USEDEP}]"
 
+PATCHES=( "${FILESDIR}"/${P}-yapsy.patch )
+
 python_compile_all() {
 	nikola tabcompletion --shell=bash > ${PN}.bashcomp || die
 	nikola tabcompletion --shell=zsh > ${PN}.zshcomp || die