# Maintainer: Marian Buschsieweke <marian.buschsieweke@posteo.net>
# Contributor: Marian Buschsieweke <marian.buschsieweke@posteo.net>
_pkgname=wxPython
pkgname=py3-wxpython
pkgver=4.2.1
pkgrel=5
pkgdesc="Cross-platform GUI toolkit for the Python language"
url="https://wxpython.org/"
arch="all"
license="custom:wxWidgets"
depends="
	python3
	py3-numpy
	py3-pillow
	py3-six
	"
makedepends="
	py3-setuptools
	py3-sip
	python3-dev
	waf
	wxwidgets-dev
	"
checkdepends="py3-pytest py3-pytest-xdist xvfb-run"
subpackages="$pkgname-doc $pkgname-lang $pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/w/wxPython/wxPython-$pkgver.tar.gz
	no-attrdict.patch
	no-stacktrace.patch
	sip-bool.patch
	update-sip-abi-version.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 !spdx"

build() {
	export CPPFLAGS="$CPPFLAGS -flto=auto"
	# regenerating sip bindings first to match local wxwidgets version,
	# then run build
	python3 build.py sip build --use_syswx --release -j${JOBS:-1}
}

check() {
	xvfb-run -a pytest
}

package() {
	python3 build.py install --destdir="$pkgdir"
	install -Dm 644 LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt
	find "$pkgdir"/usr/lib -type f -exec chmod 644 {} \;
}

lang() {
	pkgdesc="translations for $pkgname"
	install_if="lang $pkgname=$pkgver-r$pkgrel"

	amove usr/lib/python3*/site-packages/wx/locale
}

sha512sums="
ee9ab8effb3c71de004c3d61ec583b9980c6b75fe9bb04cf2c76025ea70afc206bc3073c44d1c83c7ba604afed9fd38c01b9ef506617ba279a4ac58e3cf34438  wxPython-4.2.1.tar.gz
461bc59bad6120f64e112688914c9e8ddf0dc34d789244025cd05210b098fe671e2b10ee37067c48a822b3e528380998935eb0d70c5aa5bf3993f6c6ad50bb43  no-attrdict.patch
ebd45621684603ca5e481d2a32e9ddf7de8dcd8c9f49745bd1e8509f6c118361d59d092032a541d56cbbe69f00f307dd507d511b425f14c733379e1f4b627719  no-stacktrace.patch
38f624e08abd270717c3d8db67fe384871fbdc0dd0f35541563d2ce262b24b321d411641d0218c2301d6ebe37a7ec2d3c0e1501ea75e2043a4971f8ada60c4ed  sip-bool.patch
ff7bb5e35ef9a4fdbb8fb6675f9a36515682c98d76e7a25537801b51209918ce78af22e7df3e141c662d1607607e8778d69091e1577d6264b48cf72d292dcbbc  update-sip-abi-version.patch
"
