commit:     ffc2f352c9ea970a5876b47121d0b93578dce7db
Author:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 27 04:30:59 2026 +0000
Commit:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
CommitDate: Tue Jan 27 04:50:20 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ffc2f352

net-irc/weechat: fix broken python detection grabbing the latest version

A deficiency in the upstream cmake files meant that cmake.eclass
enforcing to use the wrapper python set up by python-single-r1.eclass,
was nonfunctional. Instead, we ended up with random pythons unrelated to
PYTHON_SINGLE_TARGET (read: selects some python-config binary with the
highest version number).

Add upstream PR to fix detection, and backport the patch.

Note that the issue here is a cmake design bug. Some ways to call
`find_package(Python COMPONENTS ...)` do not support *any* method of
setting the right python to find. It is possible to set *some*
individual sub-elements of the found python via -DXXX options querying
python-utils-r1.eclass, but this is a hack and not reasonably scalable.
It really needs to be fixed upstream.

Closes: https://bugs.gentoo.org/968814
Bug: https://github.com/weechat/weechat/pull/2299
Bug: https://github.com/gentoo/gentoo/pull/45437
Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org>

 ...broken-usage-of-FindPython.cmake-breaking.patch | 59 ++++++++++++++++++++++
 ...eechat-4.7.2.ebuild => weechat-4.7.2-r1.ebuild} |  4 ++
 2 files changed, 63 insertions(+)

diff --git 
a/net-irc/weechat/files/weechat-4.7.2-python-fix-broken-usage-of-FindPython.cmake-breaking.patch
 
b/net-irc/weechat/files/weechat-4.7.2-python-fix-broken-usage-of-FindPython.cmake-breaking.patch
new file mode 100644
index 000000000000..d2024aa0f3d0
--- /dev/null
+++ 
b/net-irc/weechat/files/weechat-4.7.2-python-fix-broken-usage-of-FindPython.cmake-breaking.patch
@@ -0,0 +1,59 @@
+From d03a7403b09b1027ffe132dc80f3a6707dc8164b Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <[email protected]>
+Date: Mon, 26 Jan 2026 22:22:12 -0500
+Subject: [PATCH] python: fix broken usage of FindPython.cmake breaking python
+ selection
+
+In commit 9a9a262ea171c1092fcab560db57bb8cc4e65ac9 we moved from
+pkg-config to find_package() to work around a deficiency in the pkgsrc
+package manager, which does not ship pkg-config files as intended by
+CPython. In the process, Gentoo and other platforms that, unlike pkgsrc,
+publicly support multiple versions of python installed in parallel, had
+python version selection broken. Consequently, weechat linked to the
+wrong python, which happened to be installed in build chroots but was
+not the versioned python package that the weechat package listed as a
+dependency. Attempting to install weechat then broke on some systems
+(which installed one version of python as a dependency but actually
+linked to a totally different one).
+
+This happens due to a design bug in upstream CMake. It is never
+conceptually reasonable to use
+
+```
+find_package(Python COMPONENTS ...)
+```
+
+and omit the "Interpreter" component; if you do, CMake will ignore its
+own documentation on how to control the build to use a specific python,
+and choose one randomly (== "latest version available"). If, and only
+if, the Interpreter component is checked, the development headers /
+libraries for python will be guaranteed consistent with the documented
+lookup variables from FindPython.cmake's documentation.
+
+Bug: https://bugs.gentoo.org/968814
+Fixes: 9a9a262ea171c1092fcab560db57bb8cc4e65ac9
+Fixes: https://github.com/weechat/weechat/pull/2251
+Signed-off-by: Eli Schwartz <[email protected]>
+---
+ src/plugins/CMakeLists.txt | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
+index 252d026e2..87385f29b 100644
+--- a/src/plugins/CMakeLists.txt
++++ b/src/plugins/CMakeLists.txt
+@@ -125,9 +125,9 @@ endif()
+ 
+ if(ENABLE_SCRIPTS AND ENABLE_PYTHON)
+   if(CMAKE_VERSION VERSION_LESS "3.18.0")
+-    find_package(Python 3.0 COMPONENTS Development)
++    find_package(Python 3.0 COMPONENTS Interpreter Development)
+   else()
+-    find_package(Python 3.0 COMPONENTS Development.Embed)
++    find_package(Python 3.0 COMPONENTS Interpreter Development.Embed)
+   endif()
+   if(Python_FOUND)
+     add_subdirectory(python)
+-- 
+2.52.0
+

diff --git a/net-irc/weechat/weechat-4.7.2.ebuild 
b/net-irc/weechat/weechat-4.7.2-r1.ebuild
similarity index 98%
rename from net-irc/weechat/weechat-4.7.2.ebuild
rename to net-irc/weechat/weechat-4.7.2-r1.ebuild
index 66d216067a51..a169d547a8df 100644
--- a/net-irc/weechat/weechat-4.7.2.ebuild
+++ b/net-irc/weechat/weechat-4.7.2-r1.ebuild
@@ -100,6 +100,10 @@ DOCS="AUTHORS.md CHANGELOG.md CONTRIBUTING.md UPGRADING.md 
README.md"
 
 RESTRICT="!test? ( test )"
 
+PATCHES=(
+       
"${FILESDIR}"/${P}-python-fix-broken-usage-of-FindPython.cmake-breaking.patch
+)
+
 maint_pkg_create() {
        pushd "${S}" > /dev/null
 

Reply via email to