# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Maintainer: Fabian Bornschein <fabiscafe@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgbase=pygobject
pkgname=(
  python-gobject
  python-gobject-docs
)
pkgver=3.48.1
pkgrel=2.1
pkgdesc="Python bindings for GLib/GObject/GIO/GTK"
url="https://wiki.gnome.org/Projects/PyGObject"
arch=(x86_64 aarch64)
license=(LGPL-2.1-or-later)
depends=(
  gobject-introspection-runtime
  python
)
makedepends=(
  git
  gobject-introspection
  meson
  python-cairo
  python-sphinx
  python-sphinx-furo
  base-devel
)
checkdepends=(
  #gtk3
  python-pytest
  #xorg-server-xvfb
)
optdepends=('cairo: Cairo bindings')
_commit=67b807613a93544fb7ff8f456b0de004950f7da4  # tags/3.48.1^0
source=(
  "git+https://gitlab.gnome.org/GNOME/pygobject.git#commit=$_commit"
  304.patch
)
b2sums=('7f0fe23cc7b882ba61de7d87379bffe32f3282a37a4fe32388f6bdb920bd42c80067dea8db25708b3e127264d9af64416cb24bf9a6b917ad15e0040870782065'
        '84b96baf978b5117a3557c56a45efc842deb415d23eeec52c98e9b7c6af3aeff3f48889c6824dc81e8efa1ca1fc016161d7f278f062f35db3058c2db05b8a540')

pkgver() {
  cd pygobject
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd pygobject

  # https://gitlab.gnome.org/GNOME/pygobject/-/issues/624
  # https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/304
  git apply -3 ../304.patch
}

build() {
  arch-meson pygobject build
  meson compile -C build
}

#check() {
  # PYTEST_ADDOPTS="-v" PYGI_TEST_VERBOSE=1 \
  #   xvfb-run -s '-nolisten local' \
  #   meson test -C build --print-errorlogs
#}

package_python-gobject() {
  provides=("pygobject-devel=$pkgver")
  conflicts=(pygobject-devel)
  replaces=('pygobject-devel<=3.36.1-1')

  meson install -C build --destdir "$pkgdir"
  python -m compileall -d /usr/lib "$pkgdir/usr/lib"
  python -O -m compileall -d /usr/lib "$pkgdir/usr/lib"
}

package_python-gobject-docs() {
  pkgdesc="Developer documentation for PyGObject"
  depends=()
  optdepends=()

  python -m sphinx -b html pygobject/docs "$pkgdir/usr/share/doc/pygobject/html"
  rm -r "$pkgdir/usr/share/doc/pygobject/html/.doctrees"
}


# vim:set sw=2 sts=-1 et:
