From 57bbd5dfcfaa9c720ce3c7161a3a78f48ab3dbdd Mon Sep 17 00:00:00 2001
From: Eloi Torrents <eloitor@disroot.org>
Date: Mon, 29 Jul 2024 13:22:12 +0200
Subject: [PATCH] New package: python3-pyqt6-qsci-2.14.1

---
 srcpkgs/python3-pyqt6-qsci-devel              |  1 +
 .../python3-pyqt6-qsci/patches/cross.patch    | 18 +++++++++
 srcpkgs/python3-pyqt6-qsci/template           | 38 +++++++++++++++++++
 srcpkgs/python3-pyqt6-qsci/update             |  2 +
 4 files changed, 59 insertions(+)
 create mode 120000 srcpkgs/python3-pyqt6-qsci-devel
 create mode 100644 srcpkgs/python3-pyqt6-qsci/patches/cross.patch
 create mode 100644 srcpkgs/python3-pyqt6-qsci/template
 create mode 100644 srcpkgs/python3-pyqt6-qsci/update

diff --git a/srcpkgs/python3-pyqt6-qsci-devel b/srcpkgs/python3-pyqt6-qsci-devel
new file mode 120000
index 00000000000..a70f9fccd39
--- /dev/null
+++ b/srcpkgs/python3-pyqt6-qsci-devel
@@ -0,0 +1 @@
+python3-pyqt6-qsci
\ No newline at end of file
diff --git a/srcpkgs/python3-pyqt6-qsci/patches/cross.patch b/srcpkgs/python3-pyqt6-qsci/patches/cross.patch
new file mode 100644
index 00000000000..81dbdf26c8c
--- /dev/null
+++ b/srcpkgs/python3-pyqt6-qsci/patches/cross.patch
@@ -0,0 +1,18 @@
+--- a/Python/project.py
++++ b/Python/project.py
+@@ -41,6 +41,15 @@ class QScintilla(PyQtProject):
+         # static or dynamic).
+         self.qsci_external_lib = not os.path.isdir('src')
+ 
++    def run_command(self, args, *, fatal=True):
++        """ Run a command and display the output if requested. """
++        qemu_machine = os.environ.get("XBPS_TARGET_QEMU_MACHINE")
++        builddir = os.environ.get("XBPS_BUILDDIR")
++        if qemu_machine and args[0].startswith(os.path.join(builddir, "python3-pyqt6-qsci")):
++            qemu = "qemu-{}-static".format(qemu_machine)
++            args.insert(0, qemu)
++        super().run_command(args, fatal=fatal)
++
+     def apply_user_defaults(self, tool):
+         """ Set default values for user options that haven't been set yet. """
+ 
diff --git a/srcpkgs/python3-pyqt6-qsci/template b/srcpkgs/python3-pyqt6-qsci/template
new file mode 100644
index 00000000000..d245c0e3ab8
--- /dev/null
+++ b/srcpkgs/python3-pyqt6-qsci/template
@@ -0,0 +1,38 @@
+# Template file for 'python3-pyqt6-qsci'
+# XXX Keep in sync with qscintilla-qt6
+# Splited because pyqt6-qsci requires qscintilla-qt6 built at configure time.
+pkgname=python3-pyqt6-qsci
+version=2.14.1
+revision=1
+build_wrksrc=Python
+build_style=sip-build
+build_helper=qemu
+hostmakedepends="qt6-base-devel qscintilla-qt6-devel python3-PyQt-builder
+ python3-pyqt6-tools-devel python3-pyqt6-printsupport-devel pkg-config"
+makedepends="qscintilla-qt6-devel qt6-tools-devel python3-devel"
+depends="python3-pyqt6"
+short_desc="Qt6 port of Scintilla editor - Python 3 binding"
+maintainer="Eloi Torrents <eloitor@duck.com>"
+license="GPL-3.0-only"
+homepage="https://www.riverbankcomputing.com/software/qscintilla/intro"
+distfiles="https://www.riverbankcomputing.com/static/Downloads/QScintilla/${version}/QScintilla_src-${version}.tar.gz"
+checksum=dfe13c6acc9d85dfcba76ccc8061e71a223957a6c02f3c343b30a9d43a4cdd4d
+lib32disabled=yes
+
+CXXFLAGS="$(printf " -I$XBPS_CROSS_BASE/usr/include/qt6/%s" \
+	QtWidgets QtPrintSupport)"
+
+post_extract() {
+	rm -rf src
+	ln -sf pyproject-qt6.toml Python/pyproject.toml
+}
+
+python3-pyqt6-qsci-devel_package() {
+	lib32disabled=yes
+	short_desc+=" - development files"
+	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
+	pkg_install() {
+		vmove ${py3_sitelib}/PyQt6/bindings
+		vmove usr/share/qt6/qsci/api
+	}
+}
diff --git a/srcpkgs/python3-pyqt6-qsci/update b/srcpkgs/python3-pyqt6-qsci/update
new file mode 100644
index 00000000000..8ddafc0f70a
--- /dev/null
+++ b/srcpkgs/python3-pyqt6-qsci/update
@@ -0,0 +1,2 @@
+site="https://www.riverbankcomputing.com/software/qscintilla/download"
+pattern='QScintilla[_a-zA-Z]*-\K[\d.]+(?=.tar.gz)'