From e4e17d08f565fca2a3d559d95a4106bfce48d47a Mon Sep 17 00:00:00 2001
From: psykose <alice@ayaya.dev>
Date: Mon, 12 Sep 2022 07:15:45 +0000
Subject: [PATCH] testing/py3-wxpython: upgrade to 4.2.0

---
 testing/py3-wxpython/APKBUILD            | 51 +++++++++++++++++-------
 testing/py3-wxpython/no-attrdict.patch   | 18 +++++++++
 testing/py3-wxpython/no-stacktrace.patch | 12 ++++++
 3 files changed, 66 insertions(+), 15 deletions(-)
 create mode 100644 testing/py3-wxpython/no-attrdict.patch
 create mode 100644 testing/py3-wxpython/no-stacktrace.patch

diff --git a/testing/py3-wxpython/APKBUILD b/testing/py3-wxpython/APKBUILD
index 98194a364beb..9344285389a3 100644
--- a/testing/py3-wxpython/APKBUILD
+++ b/testing/py3-wxpython/APKBUILD
@@ -2,34 +2,44 @@
 # Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
 _pkgname=wxPython
 pkgname=py3-wxpython
-pkgver=4.0.7
-pkgrel=3
+pkgver=4.2.0
+pkgrel=0
 pkgdesc="Cross-platform GUI toolkit for the Python language"
 url="https://wxpython.org/"
 arch="all"
-license="custom"
-depends="py3-six py3-pathlib2"
-makedepends="py3-setuptools wxgtk3-dev python3-dev"
+license="custom:wxWidgets"
+depends="
+	python3
+	py3-numpy
+	py3-pillow
+	py3-six
+	"
+makedepends="
+	py3-setuptools
+	py3-sip
+	python3-dev
+	wxwidgets-dev
+	"
 checkdepends="py3-pytest py3-pytest-xdist xvfb-run"
-source="https://files.pythonhosted.org/packages/source/w/wxPython/wxPython-$pkgver.tar.gz"
+subpackages="$pkgname-doc $pkgname-lang"
+source="https://files.pythonhosted.org/packages/source/w/wxPython/wxPython-$pkgver.tar.gz
+	no-attrdict.patch
+	no-stacktrace.patch
+	"
 builddir="$srcdir"/$_pkgname-$pkgver
 # Not all unit tests are passing. Some due to missing features of xvfb where the
 # tests are running in (GL, display settings). Some are checking features that
 # have not been provided in this package. Disabling failing unit tests to track
 # regressions would be nice, but I do not have the time for that now
-options="!check"
-
-prepare() {
-	default_prepare
-	sed -i "s|WX_CONFIG = 'wx-config'|WX_CONFIG = 'wx-config-gtk3'|" build.py
-}
+options="!check !spdx"
 
 build() {
-	python3 build.py build --use_syswx --release
+	export CPPFLAGS="$CPPFLAGS -flto=auto"
+	python3 build.py build --use_syswx --release -j${JOBS:-1}
 }
 
 check() {
-	xvfb-run python3 build.py test
+	xvfb-run -a pytest
 }
 
 package() {
@@ -38,4 +48,15 @@ package() {
 	find "$pkgdir"/usr/lib -type f -exec chmod 644 {} \;
 }
 
-sha512sums="22d74a1285de432dd251ed6343b6138411a70742a7026e1ab002e08b84f111123382625bd64055412687d9ba7b579681d9894a58705455eb6a2b5e3c9d9985c0  wxPython-4.0.7.tar.gz"
+lang() {
+	pkgdesc="translations for $pkgname"
+	install_if="lang $pkgname=$pkgver-r$pkgrel"
+
+	amove usr/lib/python3*/site-packages/wx/locale
+}
+
+sha512sums="
+9ec937a024efb2916403c84382a66004f0c2bb07471246b7de517778309ce459e929eeb59e261f538d3fa077c950628de62e49a3760fbd03ab9ff2114c6f354f  wxPython-4.2.0.tar.gz
+ac7004cf6280242af3e6265d69ac909f7c1fcd37d9da625704f1e0ea23be76821cd259c48bf589380b6e84f9fdfc28d6372dfb155188a48a49e3361731e7461f  no-attrdict.patch
+ebd45621684603ca5e481d2a32e9ddf7de8dcd8c9f49745bd1e8509f6c118361d59d092032a541d56cbbe69f00f307dd507d511b425f14c733379e1f4b627719  no-stacktrace.patch
+"
diff --git a/testing/py3-wxpython/no-attrdict.patch b/testing/py3-wxpython/no-attrdict.patch
new file mode 100644
index 000000000000..d61aff03e0d2
--- /dev/null
+++ b/testing/py3-wxpython/no-attrdict.patch
@@ -0,0 +1,18 @@
+this is a very abandoned python module, easier to just patch in this
+diff --git a/buildtools/config.py b/buildtools/config.py
+index 20a2fd9d..fa16befd 100644
+--- a/buildtools/config.py
++++ b/buildtools/config.py
+@@ -27,7 +27,11 @@ from distutils.dep_util  import newer
+ 
+ import distutils.sysconfig
+ 
+-from attrdict import AttrDict
++class AttrDict(dict):
++    def __getattr__(self, attr):
++        return self[attr]
++    def __setattr__(self, attr, value):
++        self[attr] = value
+ 
+ runSilently = False
+ 
diff --git a/testing/py3-wxpython/no-stacktrace.patch b/testing/py3-wxpython/no-stacktrace.patch
new file mode 100644
index 000000000000..ef761587e977
--- /dev/null
+++ b/testing/py3-wxpython/no-stacktrace.patch
@@ -0,0 +1,12 @@
+we have no stacktraces in wxwidgets
+--- a/sip/cpp/sip_corewxAppTraits.cpp
++++ b/sip/cpp/sip_corewxAppTraits.cpp
+@@ -471,7 +471,7 @@
+             PyErr_Clear();
+ 
+             Py_BEGIN_ALLOW_THREADS
+-            sipRes = new  ::wxString((sipSelfWasArg ? sipCpp-> ::wxAppTraits::GetAssertStackTrace() : sipCpp->GetAssertStackTrace()));
++            sipRes = new  ::wxString("");
+             Py_END_ALLOW_THREADS
+ 
+             if (PyErr_Occurred())
-- 
GitLab