From 1b568ddb4073741907afb53ab16d17ad4f5430f1 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Sat, 26 Jul 2025 19:10:41 +0300
Subject: dev-python/pytqt: several changes

* fix FTBFS in stables
* add python_optimize calls
* add correct python version to DEPENDs

Bug: https://mirror.git.trinitydesktop.org/gitea/TDE/tde-packaging-gentoo/issues/405
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
---
 ...hanging-string-types-to-bytes-for-pytquic.patch | 44 +++++++++++++
 .../pytqt-14.1.2-Fix-FTBFS-with-Python-3.13.patch  | 40 ++++++++++++
 dev-python/pytqt/files/pytqt-pytquic.patch         | 44 -------------
 dev-python/pytqt/pytqt-14.1.1-r1.ebuild            | 74 ++++++++++++++++++++++
 dev-python/pytqt/pytqt-14.1.1.ebuild               | 68 --------------------
 dev-python/pytqt/pytqt-14.1.2-r1.ebuild            | 74 ++++++++++++++++++++++
 dev-python/pytqt/pytqt-14.1.2.ebuild               | 69 --------------------
 dev-python/pytqt/pytqt-9999.ebuild                 |  7 +-
 8 files changed, 236 insertions(+), 184 deletions(-)
 create mode 100644 dev-python/pytqt/files/pytqt-14.1.2-Changing-string-types-to-bytes-for-pytquic.patch
 create mode 100644 dev-python/pytqt/files/pytqt-14.1.2-Fix-FTBFS-with-Python-3.13.patch
 delete mode 100644 dev-python/pytqt/files/pytqt-pytquic.patch
 create mode 100644 dev-python/pytqt/pytqt-14.1.1-r1.ebuild
 delete mode 100644 dev-python/pytqt/pytqt-14.1.1.ebuild
 create mode 100644 dev-python/pytqt/pytqt-14.1.2-r1.ebuild
 delete mode 100644 dev-python/pytqt/pytqt-14.1.2.ebuild

diff --git a/dev-python/pytqt/files/pytqt-14.1.2-Changing-string-types-to-bytes-for-pytquic.patch b/dev-python/pytqt/files/pytqt-14.1.2-Changing-string-types-to-bytes-for-pytquic.patch
new file mode 100644
index 00000000..09119cd2
--- /dev/null
+++ b/dev-python/pytqt/files/pytqt-14.1.2-Changing-string-types-to-bytes-for-pytquic.patch
@@ -0,0 +1,44 @@
+diff --git a/pytquic3/form.cpp b/pytquic3/form.cpp
+index b0de614..323161e 100644
+--- a/pytquic3/form.cpp
++++ b/pytquic3/form.cpp
+@@ -340,12 +340,12 @@ void Uic::createFormImpl( const TQDomElement &e )
+ 			images += img;
+ 			out << indent << img << "_data = \\" << endl;
+ 			++indent;
+-			out << indent << "\"";
++			out << indent << "b\"";
+ 			int a ;
+ 			for ( a = 0; a < (int) (data.length()/2)-1; a++ ) {
+ 			    out << "\\x" << TQString(data[2*a]) << TQString(data[2*a+1]);
+ 			    if ( a % 12 == 11 )
+-				out << "\" \\" << endl << indent << "\"";
++				out << "\" \\" << endl << indent << "b\"";
+ 			}
+ 			out << "\\x" << TQString(data[2*a]) << TQString(data[2*a+1]) << "\"" << endl;
+ 			--indent;
+@@ -391,7 +391,7 @@ void Uic::createFormImpl( const TQDomElement &e )
+ 	TQStringList::Iterator it;
+ 	for ( it = images.begin(); it != images.end(); ++it ) {
+ 	    out << indent << "self." << (*it) << " = TQPixmap()" << endl;
+-	    out << indent << "self." << (*it) << ".loadFromData(" << (*it) << "_data,\"PNG\")" << endl;
++	    out << indent << "self." << (*it) << ".loadFromData(" << (*it) << "_data,b\"PNG\")" << endl;
+ 	}
+     }
+     // create pixmaps for all images
+diff --git a/pytquic3/uic.cpp b/pytquic3/uic.cpp
+index d5d89dc..e4a5ad0 100644
+--- a/pytquic3/uic.cpp
++++ b/pytquic3/uic.cpp
+@@ -387,9 +387,9 @@ void Uic::createActionImpl( const TQDomElement &n, const TQString &parent )
+     for ( TQDomElement ae = n; !ae.isNull(); ae = ae.nextSibling().toElement() ) {
+ 	TQString objName = registerObject( getObjectName( ae ) );
+ 	if ( ae.tagName() == "action" )
+-	    out << indent << "self." << objName << " = TQAction(" << parent << ",\"" << objName << "\")" << endl;
++	    out << indent << "self." << objName << " = TQAction(" << parent << ",b\"" << objName << "\")" << endl;
+ 	else if ( ae.tagName() == "actiongroup" )
+-	    out << indent << "self." << objName << " = TQActionGroup(" << parent << ",\"" << objName << "\")" << endl;
++	    out << indent << "self." << objName << " = TQActionGroup(" << parent << ",b\"" << objName << "\")" << endl;
+ 	else
+ 	    continue;
+ 	bool subActionsDone = FALSE;
diff --git a/dev-python/pytqt/files/pytqt-14.1.2-Fix-FTBFS-with-Python-3.13.patch b/dev-python/pytqt/files/pytqt-14.1.2-Fix-FTBFS-with-Python-3.13.patch
new file mode 100644
index 00000000..f23b1b5d
--- /dev/null
+++ b/dev-python/pytqt/files/pytqt-14.1.2-Fix-FTBFS-with-Python-3.13.patch
@@ -0,0 +1,40 @@
+From 5afb6e8ec49253cda4285b4a0ca76a37f0d30689 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fran=C3=A7ois=20Andriot?= <albator78@libertysurf.fr>
+Date: Wed, 25 Sep 2024 21:01:39 +0200
+Subject: [PATCH 1/3] Fix FTBFS with Python 3.13. This solves issue #32.
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: François Andriot <albator78@libertysurf.fr>
+(cherry picked from commit d0ab12dc39963aa28698943bf4ad88d3fd3d4c51)
+---
+ sip/tqt/tqstring.sip | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/sip/tqt/tqstring.sip b/sip/tqt/tqstring.sip
+index 8ef101f..6e09d0f 100644
+--- a/sip/tqt/tqstring.sip
++++ b/sip/tqt/tqstring.sip
+@@ -890,9 +890,16 @@ const char *PyTQt_tqt_encode(PyObject **s, TQApplication::Encoding encoding)
+         es = PyBytes_AS_STRING(obj);
+         Py_INCREF(obj);
+     }
+-    else if (PyObject_AsCharBuffer(obj, &es, &sz) >= 0)
++    else
+     {
+-        Py_INCREF(obj);
++        Py_buffer view;
++
++        if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) == 0) {
++            es = (const char*)view.buf;
++            sz = view.len;
++            PyBuffer_Release(&view);
++            Py_INCREF(obj);
++        }
+     }
+ 
+     if (es)
+-- 
+2.49.1
+
diff --git a/dev-python/pytqt/files/pytqt-pytquic.patch b/dev-python/pytqt/files/pytqt-pytquic.patch
deleted file mode 100644
index 09119cd2..00000000
--- a/dev-python/pytqt/files/pytqt-pytquic.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-diff --git a/pytquic3/form.cpp b/pytquic3/form.cpp
-index b0de614..323161e 100644
---- a/pytquic3/form.cpp
-+++ b/pytquic3/form.cpp
-@@ -340,12 +340,12 @@ void Uic::createFormImpl( const TQDomElement &e )
- 			images += img;
- 			out << indent << img << "_data = \\" << endl;
- 			++indent;
--			out << indent << "\"";
-+			out << indent << "b\"";
- 			int a ;
- 			for ( a = 0; a < (int) (data.length()/2)-1; a++ ) {
- 			    out << "\\x" << TQString(data[2*a]) << TQString(data[2*a+1]);
- 			    if ( a % 12 == 11 )
--				out << "\" \\" << endl << indent << "\"";
-+				out << "\" \\" << endl << indent << "b\"";
- 			}
- 			out << "\\x" << TQString(data[2*a]) << TQString(data[2*a+1]) << "\"" << endl;
- 			--indent;
-@@ -391,7 +391,7 @@ void Uic::createFormImpl( const TQDomElement &e )
- 	TQStringList::Iterator it;
- 	for ( it = images.begin(); it != images.end(); ++it ) {
- 	    out << indent << "self." << (*it) << " = TQPixmap()" << endl;
--	    out << indent << "self." << (*it) << ".loadFromData(" << (*it) << "_data,\"PNG\")" << endl;
-+	    out << indent << "self." << (*it) << ".loadFromData(" << (*it) << "_data,b\"PNG\")" << endl;
- 	}
-     }
-     // create pixmaps for all images
-diff --git a/pytquic3/uic.cpp b/pytquic3/uic.cpp
-index d5d89dc..e4a5ad0 100644
---- a/pytquic3/uic.cpp
-+++ b/pytquic3/uic.cpp
-@@ -387,9 +387,9 @@ void Uic::createActionImpl( const TQDomElement &n, const TQString &parent )
-     for ( TQDomElement ae = n; !ae.isNull(); ae = ae.nextSibling().toElement() ) {
- 	TQString objName = registerObject( getObjectName( ae ) );
- 	if ( ae.tagName() == "action" )
--	    out << indent << "self." << objName << " = TQAction(" << parent << ",\"" << objName << "\")" << endl;
-+	    out << indent << "self." << objName << " = TQAction(" << parent << ",b\"" << objName << "\")" << endl;
- 	else if ( ae.tagName() == "actiongroup" )
--	    out << indent << "self." << objName << " = TQActionGroup(" << parent << ",\"" << objName << "\")" << endl;
-+	    out << indent << "self." << objName << " = TQActionGroup(" << parent << ",b\"" << objName << "\")" << endl;
- 	else
- 	    continue;
- 	bool subActionsDone = FALSE;
diff --git a/dev-python/pytqt/pytqt-14.1.1-r1.ebuild b/dev-python/pytqt/pytqt-14.1.1-r1.ebuild
new file mode 100644
index 00000000..814d7ab6
--- /dev/null
+++ b/dev-python/pytqt/pytqt-14.1.1-r1.ebuild
@@ -0,0 +1,74 @@
+# Copyright 2022-2025 The Trinity Desktop Project
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="8"
+
+TRINITY_MODULE_TYPE="dependencies"
+PYTHON_COMPAT=( python3_{8..13} )
+
+inherit trinity-base-2 python-single-r1 flag-o-matic
+
+DESCRIPTION="TQt bindings for Python"
+HOMEPAGE="https://trinitydesktop.org/"
+LICENSE="GPL-2"
+SLOT="0"
+if [[ ${PV} != *9999* ]] ; then
+	KEYWORDS="~amd64 ~arm64 ~x86"
+fi
+IUSE="examples"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+DEPEND="${PYTHON_DEPS}
+	~dev-python/sip4-tqt-${PV}[${PYTHON_SINGLE_USEDEP}]
+	~x11-libs/tqscintilla-${PV}
+	~dev-tqt/tqtinterface-${PV}
+"
+RDEPEND="${DEPEND}"
+
+TQBASE="/usr/tqt3"
+BUILD_DIR="${S}"
+
+PATCHES=(
+	"${FILESDIR}/${P}-Changing-string-types-to-bytes-for-pytquic.patch"
+	"${FILESDIR}/${PN}-14.1.2-Fix-FTBFS-with-Python-3.13.patch"
+)
+
+src_prepare() {
+	default
+}
+
+src_configure() {
+	append-cflags "-I/usr/include/tqt -I/${TQBASE}/include"
+	append-cxxflags "-I/usr/include/tqt -I/${TQBASE}/include"
+	local myconf
+	myconf=(
+	-g "${TQBASE}/include"
+	-q "${TQBASE}"
+	-y tqt-mt
+	-o "${TQBASE}/$(get_libdir)" -u -j 10
+	-d "$(python_get_sitedir)/PyTQt"
+	-v "${TQBASE}/sip/tqt"
+	-b "${TQBASE}/bin"
+	-w
+	)
+	echo yes | "${EPYTHON}" configure.py "${myconf[@]}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}"|| die
+}
+
+src_compile() {
+	emake
+}
+
+src_install() {
+	emake install DESTDIR="${D}"
+	if use examples ; then
+		insinto "${TQBASE}/share/pytqt/examples"
+		doins examples/*
+		local EDIR
+		for EDIR in SQL canvas i18n webbrowser
+		do
+			insinto "${TQBASE}/share/pytqt/examples/${EDIR}"
+			doins "examples/${EDIR}"/*
+		done
+	fi
+	python_optimize
+}
diff --git a/dev-python/pytqt/pytqt-14.1.1.ebuild b/dev-python/pytqt/pytqt-14.1.1.ebuild
deleted file mode 100644
index 06db22cb..00000000
--- a/dev-python/pytqt/pytqt-14.1.1.ebuild
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright 2022-2023 The Trinity Desktop Project
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="8"
-
-TRINITY_MODULE_TYPE="dependencies"
-PYTHON_COMPAT=( python3_{8..13} )
-
-inherit trinity-base-2 python-single-r1 flag-o-matic
-
-DESCRIPTION="TQt bindings for Python"
-HOMEPAGE="https://trinitydesktop.org/"
-LICENSE="GPL-2"
-SLOT="0"
-if [[ ${PV} != *9999* ]] ; then
-	KEYWORDS="~amd64 ~arm64 ~x86"
-fi
-IUSE="examples"
-REQUIRED_USE="${PYTHON_REQUIRED_USE}"
-
-DEPEND="${PYTHON_DEPS}
-	~dev-python/sip4-tqt-${PV}
-	~x11-libs/tqscintilla-${PV}
-	~dev-tqt/tqtinterface-${PV}
-"
-RDEPEND="${DEPEND}"
-
-TQBASE="/usr/tqt3"
-BUILD_DIR="${S}"
-
-src_prepare() {
-	eapply_user
-}
-
-src_configure() {
-	append-cflags "-I/usr/include/tqt -I/${TQBASE}/include"
-	append-cxxflags "-I/usr/include/tqt -I/${TQBASE}/include"
-	local myconf
-	myconf=(
-	-g "${TQBASE}/include"
-	-q "${TQBASE}"
-	-y tqt-mt
-	-o "${TQBASE}/$(get_libdir)" -u -j 10
-	-d "$(python_get_sitedir)/PyTQt"
-	-v "${TQBASE}/sip/tqt"
-	-b "${TQBASE}/bin"
-	-w
-	)
-	echo yes | "${EPYTHON}" configure.py "${myconf[@]}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}"|| die
-}
-
-src_compile() {
-	emake
-}
-
-src_install() {
-	emake install DESTDIR="${D}"
-	if use examples ; then
-		insinto "${TQBASE}/share/pytqt/examples"
-		doins examples/*
-		local EDIR
-		for EDIR in SQL canvas i18n webbrowser
-		do
-			insinto "${TQBASE}/share/pytqt/examples/${EDIR}"
-			doins "examples/${EDIR}"/*
-		done
-	fi
-}
diff --git a/dev-python/pytqt/pytqt-14.1.2-r1.ebuild b/dev-python/pytqt/pytqt-14.1.2-r1.ebuild
new file mode 100644
index 00000000..7d8a0212
--- /dev/null
+++ b/dev-python/pytqt/pytqt-14.1.2-r1.ebuild
@@ -0,0 +1,74 @@
+# Copyright 2022-2025 The Trinity Desktop Project
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="8"
+
+TRINITY_MODULE_TYPE="dependencies"
+PYTHON_COMPAT=( python3_{8..13} )
+
+inherit trinity-base-2 python-single-r1 flag-o-matic
+
+DESCRIPTION="TQt bindings for Python"
+HOMEPAGE="https://trinitydesktop.org/"
+LICENSE="GPL-2"
+SLOT="0"
+if [[ ${PV} != *9999* ]] ; then
+	KEYWORDS="~amd64 ~arm64 ~x86"
+fi
+IUSE="examples"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+DEPEND="${PYTHON_DEPS}
+	~dev-python/sip4-tqt-${PV}[${PYTHON_SINGLE_USEDEP}]
+	~x11-libs/tqscintilla-${PV}
+	~dev-tqt/tqtinterface-${PV}
+"
+RDEPEND="${DEPEND}"
+
+TQBASE="/usr/tqt3"
+BUILD_DIR="${S}"
+
+PATCHES=(
+	"${FILESDIR}/${P}-Changing-string-types-to-bytes-for-pytquic.patch"
+	"${FILESDIR}/${P}-Fix-FTBFS-with-Python-3.13.patch"
+)
+
+src_prepare() {
+	default
+}
+
+src_configure() {
+	append-cflags "-I/usr/include/tqt -I/${TQBASE}/include"
+	append-cxxflags "-I/usr/include/tqt -I/${TQBASE}/include"
+	local myconf
+	myconf=(
+	-g "${TQBASE}/include"
+	-q "${TQBASE}"
+	-y tqt-mt
+	-o "${TQBASE}/$(get_libdir)" -u -j 10
+	-d "$(python_get_sitedir)/PyTQt"
+	-v "${TQBASE}/sip/tqt"
+	-b "${TQBASE}/bin"
+	-w
+	)
+	echo yes | "${EPYTHON}" configure.py "${myconf[@]}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}"|| die
+}
+
+src_compile() {
+	emake
+}
+
+src_install() {
+	emake install DESTDIR="${D}"
+	if use examples ; then
+		insinto "${TQBASE}/share/pytqt/examples"
+		doins examples/*
+		local EDIR
+		for EDIR in SQL canvas i18n webbrowser
+		do
+			insinto "${TQBASE}/share/pytqt/examples/${EDIR}"
+			doins "examples/${EDIR}"/*
+		done
+	fi
+	python_optimize
+}
diff --git a/dev-python/pytqt/pytqt-14.1.2.ebuild b/dev-python/pytqt/pytqt-14.1.2.ebuild
deleted file mode 100644
index 928f9c12..00000000
--- a/dev-python/pytqt/pytqt-14.1.2.ebuild
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright 2022-2024 The Trinity Desktop Project
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI="8"
-
-TRINITY_MODULE_TYPE="dependencies"
-PYTHON_COMPAT=( python3_{8..13} )
-
-inherit trinity-base-2 python-single-r1 flag-o-matic
-
-DESCRIPTION="TQt bindings for Python"
-HOMEPAGE="https://trinitydesktop.org/"
-LICENSE="GPL-2"
-SLOT="0"
-if [[ ${PV} != *9999* ]] ; then
-	KEYWORDS="~amd64 ~arm64 ~x86"
-fi
-IUSE="examples"
-REQUIRED_USE="${PYTHON_REQUIRED_USE}"
-
-DEPEND="${PYTHON_DEPS}
-	~dev-python/sip4-tqt-${PV}
-	~x11-libs/tqscintilla-${PV}
-	~dev-tqt/tqtinterface-${PV}
-"
-RDEPEND="${DEPEND}"
-
-TQBASE="/usr/tqt3"
-BUILD_DIR="${S}"
-
-src_prepare() {
-	eapply "${FILESDIR}/${PN}-pytquic.patch"
-	eapply_user
-}
-
-src_configure() {
-	append-cflags "-I/usr/include/tqt -I/${TQBASE}/include"
-	append-cxxflags "-I/usr/include/tqt -I/${TQBASE}/include"
-	local myconf
-	myconf=(
-	-g "${TQBASE}/include"
-	-q "${TQBASE}"
-	-y tqt-mt
-	-o "${TQBASE}/$(get_libdir)" -u -j 10
-	-d "$(python_get_sitedir)/PyTQt"
-	-v "${TQBASE}/sip/tqt"
-	-b "${TQBASE}/bin"
-	-w
-	)
-	echo yes | "${EPYTHON}" configure.py "${myconf[@]}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}"|| die
-}
-
-src_compile() {
-	emake
-}
-
-src_install() {
-	emake install DESTDIR="${D}"
-	if use examples ; then
-		insinto "${TQBASE}/share/pytqt/examples"
-		doins examples/*
-		local EDIR
-		for EDIR in SQL canvas i18n webbrowser
-		do
-			insinto "${TQBASE}/share/pytqt/examples/${EDIR}"
-			doins "examples/${EDIR}"/*
-		done
-	fi
-}
diff --git a/dev-python/pytqt/pytqt-9999.ebuild b/dev-python/pytqt/pytqt-9999.ebuild
index f2fe1e57..e000c8ec 100644
--- a/dev-python/pytqt/pytqt-9999.ebuild
+++ b/dev-python/pytqt/pytqt-9999.ebuild
@@ -1,4 +1,4 @@
-# Copyright 2022-2023 The Trinity Desktop Project
+# Copyright 2022-2025 The Trinity Desktop Project
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI="8"
@@ -19,7 +19,7 @@ IUSE="examples"
 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
 
 DEPEND="${PYTHON_DEPS}
-	~dev-python/sip4-tqt-${PV}
+	~dev-python/sip4-tqt-${PV}[${PYTHON_SINGLE_USEDEP}]
 	~x11-libs/tqscintilla-${PV}
 	~dev-tqt/tqt-${PV}
 "
@@ -29,7 +29,7 @@ TQBASE="/usr/tqt3"
 BUILD_DIR="${S}"
 
 src_prepare() {
-	eapply_user
+	default
 }
 
 src_configure() {
@@ -65,4 +65,5 @@ src_install() {
 			doins "examples/${EDIR}"/*
 		done
 	fi
+	python_optimize
 }
-- 
cgit v1.2.3

