# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>
# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=python-wxpython
_pkgname=wxPython
pkgver=4.2.3
_pkgver="${pkgver%.*}"
_post="${pkgver##*.}"
pkgrel=3
epoch=1
pkgdesc='Cross-platform GUI toolkit'
arch=('x86_64' 'aarch64')
license=('custom:wxWindows')
url='https://www.wxpython.org'
depends=('wxwidgets-gtk3' 'python')
optdepends=('python-pypubsub: Alternative to the deprecated wx.lib.pubsub API')
makedepends=('mesa' 'glu' 'webkit2gtk-4.1' 'python-requests' 'python-setuptools' 'python-attrdict' 'sip' 'doxygen' 'waf')
checkdepends=('xorg-server-xvfb' 'python-pytest-forked' 'python-numpy')
source=("https://files.pythonhosted.org/packages/source/w/wxPython/wxPython-$pkgver.tar.gz")
sha512sums=('c7b9f0758b9d77dbeab436e8069c024796b6f252af5043615e14083b3f62fb44386c5f325a118f9e2d99c15eeb7687bb1cc1a13a00263114689b32e2126364a7')

build() {
  cd $_pkgname-$pkgver

#  rm -r sip/{cpp,gen}/* # Recreate sip files with current wxWidgets - broken with doxygen 1.9.7 https://github.com/wxWidgets/Phoenix/issues/2414
  SIP=/usr/bin/sip DOXYGEN=/usr/bin/doxygen WAF=/usr/bin/waf \
  python build.py --nodoc sip build --use_syswx --release
}

check() {
  cd $_pkgname-$pkgver

  # there are segfaulting tests so --forked ensures we get sensible results
  PYTHONPATH=$PWD xvfb-run pytest --forked unittests || echo "==> WARNING: tests usually fail randomly"
}

package() {
  cd $_pkgname-$pkgver

  python build.py install --destdir="$pkgdir"

  install -Dm 644 LICENSE.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt
  find "$pkgdir/usr/lib" -type f | xargs chmod 644
}
