From 4c79e870aff34fcae7767393b372a9548f667426 Mon Sep 17 00:00:00 2001 From: Eli Schwartz 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 --- src/plugins/python/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/python/CMakeLists.txt b/src/plugins/python/CMakeLists.txt index baa492483..c0003a1ae 100644 --- a/src/plugins/python/CMakeLists.txt +++ b/src/plugins/python/CMakeLists.txt @@ -20,9 +20,9 @@ # if(CMAKE_VERSION VERSION_LESS "3.18.0") - find_package(Python 3.0 REQUIRED COMPONENTS Development) + find_package(Python 3.0 REQUIRED COMPONENTS Interpreter Development) else() - find_package(Python 3.0 REQUIRED COMPONENTS Development.Embed) + find_package(Python 3.0 REQUIRED COMPONENTS Interpreter Development.Embed) endif() add_library(python MODULE