From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1688255-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 (4096 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 6E5A4158042
	for <garchives@archives.gentoo.org>; Sat,  9 Nov 2024 15:21:14 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 68035E0855;
	Sat,  9 Nov 2024 15:21:13 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(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 504F5E0855
	for <gentoo-commits@lists.gentoo.org>; Sat,  9 Nov 2024 15:21:13 +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 50EEA33BE12
	for <gentoo-commits@lists.gentoo.org>; Sat,  9 Nov 2024 15:21:12 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id AB0441953
	for <gentoo-commits@lists.gentoo.org>; Sat,  9 Nov 2024 15:21:10 +0000 (UTC)
From: "Andreas Sturmlechner" <asturm@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, "Andreas Sturmlechner" <asturm@gentoo.org>
Message-ID: <1731165663.8dd5f0f7a9f4843408399974ebb8dc35de768e33.asturm@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: media-gfx/krita/files/, media-gfx/krita/
X-VCS-Repository: repo/gentoo
X-VCS-Files: media-gfx/krita/files/krita-5.2.6-py3.13.patch media-gfx/krita/krita-5.2.6.ebuild
X-VCS-Directories: media-gfx/krita/files/ media-gfx/krita/
X-VCS-Committer: asturm
X-VCS-Committer-Name: Andreas Sturmlechner
X-VCS-Revision: 8dd5f0f7a9f4843408399974ebb8dc35de768e33
X-VCS-Branch: master
Date: Sat,  9 Nov 2024 15:21:10 +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: d131e169-2f82-4acf-9ce6-1697f4f05978
X-Archives-Hash: 7663b513d90d64404b46af4b64a70b8f

commit:     8dd5f0f7a9f4843408399974ebb8dc35de768e33
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  9 15:16:23 2024 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Sat Nov  9 15:21:03 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8dd5f0f7

media-gfx/krita: enable py3.13

KDE-bug: https://bugs.kde.org/show_bug.cgi?id=488680
See also: https://bugzilla.redhat.com/show_bug.cgi?id=2278646

Closes: https://bugs.gentoo.org/943149
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 media-gfx/krita/files/krita-5.2.6-py3.13.patch | 120 +++++++++++++++++++++++++
 media-gfx/krita/krita-5.2.6.ebuild             |   4 +-
 2 files changed, 123 insertions(+), 1 deletion(-)

diff --git a/media-gfx/krita/files/krita-5.2.6-py3.13.patch b/media-gfx/krita/files/krita-5.2.6-py3.13.patch
new file mode 100644
index 000000000000..6714059895d0
--- /dev/null
+++ b/media-gfx/krita/files/krita-5.2.6-py3.13.patch
@@ -0,0 +1,120 @@
+From 0f43ec3158225092f6a02422eb90c56421326570 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= <zebob.m@gmail.com>
+Date: Tue, 18 Jun 2024 22:05:34 +0200
+Subject: [PATCH] Changes to build pykrita with Python 3.13
+
+Python 3.11 deprecated Py_SetPath() in 2022 and Python 3.13 removed it.
+Instead one needs to use the new PyConfig API (PEP 587) added to Python
+3.8.
+
+Fix: #488680
+---
+ .../extensions/pykrita/plugin/utilities.cpp   | 61 +++++++++++++++++--
+ plugins/extensions/pykrita/plugin/utilities.h |  4 +-
+ 2 files changed, 57 insertions(+), 8 deletions(-)
+
+diff --git a/plugins/extensions/pykrita/plugin/utilities.cpp b/plugins/extensions/pykrita/plugin/utilities.cpp
+index 4f58183238..1e497b2681 100644
+--- a/plugins/extensions/pykrita/plugin/utilities.cpp
++++ b/plugins/extensions/pykrita/plugin/utilities.cpp
+@@ -19,8 +19,10 @@
+ #include <cmath>
+ #include <Python.h>
+ 
++#include <QDebug>
+ #include <QDir>
+ #include <QLibrary>
++#include <QProcessEnvironment>
+ #include <QString>
+ #include <QStringList>
+ #include <QVector>
+@@ -412,18 +414,65 @@ bool Python::setPath(const QStringList& scriptPaths)
+         joinedPaths = joinedPaths + pathSeparator + originalPath;
+     }
+     dbgScript << "Setting python paths:" << joinedPaths;
++
+ #ifdef Q_OS_WIN
+-    QVector<wchar_t> joinedPathsWChars(joinedPaths.size() + 1, 0);
+-    joinedPaths.toWCharArray(joinedPathsWChars.data());
+-    Py_SetPath(joinedPathsWChars.data());
++    PyStatus status;
++    PyConfig config;
++    PyConfig_InitPythonConfig(&config);
++
++    for (const QString& path : joinedPaths.split(pathSeparator)) {
++        status = PyWideStringList_Append(&config.module_search_paths, path.toStdWString().c_str());
++        if (PyStatus_Exception(status)) {
++            qDebug() << "Error appending to PyWideStringList:" << status.err_msg;
++            dbgScript << "Error appending to PyWideStringList";
++            return false;
++        }
++    }
++
++    config.module_search_paths_set = true;
++    qDebug() << "Set module_search_paths";
++
++    status = Py_InitializeFromConfig(&config);
++    if (PyStatus_Exception(status)) {
++        qDebug() << "Cannot initialize Py_InitializeFromConfig:" << status.err_msg;
++        Py_ExitStatusException(status);
++        PyConfig_Clear(&config);
++        dbgScript << "Cannot initialize Py_InitializeFromConfig config";
++        return false;
++    }
++
++    PyConfig_Clear(&config);
+ #else
+     if (runningInBundle) {
+-        QVector<wchar_t> joinedPathsWChars(joinedPaths.size() + 1, 0);
+-        joinedPaths.toWCharArray(joinedPathsWChars.data());
+-        Py_SetPath(joinedPathsWChars.data());
++        PyStatus status;
++        PyConfig config;
++        PyConfig_InitPythonConfig(&config);
++
++        for (const QString& path : joinedPaths.split(pathSeparator)) {
++            status = PyWideStringList_Append(&config.module_search_paths, path.toStdWString().c_str());
++            if (PyStatus_Exception(status)) {
++                qDebug() << "Error appending to PyWideStringList:" << status.err_msg;
++                dbgScript << "Error appending to PyWideStringList";
++                return false;
++            }
++        }
++
++        config.module_search_paths_set = true;
++
++        status = Py_InitializeFromConfig(&config);
++        if (PyStatus_Exception(status)) {
++            Py_ExitStatusException(status);
++            qDebug() << "Cannot initialize Py_InitializeFromConfig 2:" << status.err_msg;
++            PyConfig_Clear(&config);
++            dbgScript << "Cannot initialize Py_InitializeFromConfig config";
++            return false;
++        }
++
++        PyConfig_Clear(&config);
+     }
+     else {
+         qputenv("PYTHONPATH", joinedPaths.toLocal8Bit());
++        qDebug() << "Set PYTHONPATH environment variable";
+     }
+ #endif
+     isPythonPathSet = true;
+diff --git a/plugins/extensions/pykrita/plugin/utilities.h b/plugins/extensions/pykrita/plugin/utilities.h
+index fb309bd0b8..aec47da239 100644
+--- a/plugins/extensions/pykrita/plugin/utilities.h
++++ b/plugins/extensions/pykrita/plugin/utilities.h
+@@ -81,8 +81,8 @@ public:
+     static bool libraryLoad();
+ 
+     /**
+-     * Set the Python paths by calling Py_SetPath. This should be called before
+-     * initialization to ensure the proper libraries get loaded.
++     * Set the Python paths by calling Py_InitializeFromConfig. This should be
++     * called before initialization to ensure the proper libraries get loaded.
+      */
+     static bool setPath(const QStringList& scriptPaths);
+ 
+-- 
+2.45.2
+

diff --git a/media-gfx/krita/krita-5.2.6.ebuild b/media-gfx/krita/krita-5.2.6.ebuild
index 0a1c86338154..dd17eae36561 100644
--- a/media-gfx/krita/krita-5.2.6.ebuild
+++ b/media-gfx/krita/krita-5.2.6.ebuild
@@ -4,7 +4,7 @@
 EAPI=8
 
 ECM_TEST="forceoptional"
-PYTHON_COMPAT=( python3_{10..12} )
+PYTHON_COMPAT=( python3_{10..13} )
 KFMIN=5.115.0
 QTMIN=5.15.12
 inherit ecm kde.org python-single-r1
@@ -96,6 +96,8 @@ PATCHES=(
 	# downstream
 	"${FILESDIR}"/${PN}-5.2.3-tests-optional.patch
 	"${FILESDIR}"/${PN}-5.2.2-fftw.patch # bug 913518
+	# Fedora, non-upstreamed:
+	"${FILESDIR}"/${P}-py3.13.patch # bug 943149
 	# git master
 	"${FILESDIR}"/${PN}-5.1.5-sip-6.8.patch # bug 919139
 )