Skip to content
Snippets Groups Projects
Verified Commit d58a2554 authored by Antonio Rojas's avatar Antonio Rojas
Browse files

upgpkg: 5.2.6-4: Python 3.13 rebuild

parent 3e18e0e4
No related branches found
Tags 23.04.3-1
No related merge requests found
pkgbase = krita
pkgdesc = Edit and paint images
pkgver = 5.2.6
pkgrel = 3
pkgrel = 4
url = https://krita.org
arch = x86_64
license = GPL3
......@@ -70,11 +70,13 @@ pkgbase = krita
source = https://download.kde.org/stable/krita/5.2.6/krita-5.2.6.tar.gz
source = https://download.kde.org/stable/krita/5.2.6/krita-5.2.6.tar.gz.sig
source = sip-6.8.patch
source = python-3.13.patch
validpgpkeys = 05D00A8B73A686789E0A156858B9596C722EA3BD
validpgpkeys = E9FB29E74ADEACC5E3035B8AB69EB4CF7468332F
validpgpkeys = 064182440C674D9F8D0F6F8B4DA79EDA231C852B
sha256sums = 48d7128554fdf4b4e92c54ae31b52af7921f47a8da6cecaa06744abbfc82d5fb
sha256sums = SKIP
sha256sums = bb3b503993030bb98a99c6a0376c65ee74d0c32c1e8932110698682eed1e3d3c
sha256sums = 439f8a95cee437bb20a4ea3bacebf99e600209672d6d9a8326e96a2d7a9cccda
pkgname = krita
......@@ -3,7 +3,7 @@
pkgname=krita
_pkgver=5.2.6
pkgver=${_pkgver/-/}
pkgrel=3
pkgrel=4
pkgdesc='Edit and paint images'
arch=(x86_64)
url='https://krita.org'
......@@ -71,16 +71,19 @@ optdepends=('kimageformats5: PSD support'
'poppler-qt5: PDF filter'
'python-pyqt5: for the Python plugins')
source=(https://download.kde.org/stable/krita/$_pkgver/$pkgname-$_pkgver.tar.gz{,.sig}
sip-6.8.patch)
sip-6.8.patch
python-3.13.patch)
sha256sums=('48d7128554fdf4b4e92c54ae31b52af7921f47a8da6cecaa06744abbfc82d5fb'
'SKIP'
'bb3b503993030bb98a99c6a0376c65ee74d0c32c1e8932110698682eed1e3d3c')
'bb3b503993030bb98a99c6a0376c65ee74d0c32c1e8932110698682eed1e3d3c'
'439f8a95cee437bb20a4ea3bacebf99e600209672d6d9a8326e96a2d7a9cccda')
validpgpkeys=('05D00A8B73A686789E0A156858B9596C722EA3BD' # Boudewijn Rempt <foundation@krita.org>
'E9FB29E74ADEACC5E3035B8AB69EB4CF7468332F' # Dmitry Kazakov (main key) <dimula73@gmail.com>
'064182440C674D9F8D0F6F8B4DA79EDA231C852B') # Stichting Krita Foundation <foundation@krita.org>
prepare() {
patch -d $pkgname-$_pkgver -p1 < sip-6.8.patch
patch -d $pkgname-$_pkgver -p1 < python-3.13.patch
}
build() {
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment