# 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.56.3
pkgrel=1
pkgdesc="Python bindings for GLib/GObject/GIO/GTK"
url="https://pygobject.gnome.org/"
arch=(x86_64 aarch64)
license=(LGPL-2.1-or-later)
depends=(
  glib2
  glibc
  gobject-introspection-runtime
  libffi
  python
)
makedepends=(
  git
  gobject-introspection
  meson
  python-cairo
  python-pydata-sphinx-theme
  python-setuptools
  python-sphinx
  python-sphinx-copybutton
)
checkdepends=(
  gdk-pixbuf2
  gtk4
  python-pytest
  xorg-server-xvfb
)
optdepends=('python-cairo: Cairo bindings')
source=(
  "git+https://gitlab.gnome.org/GNOME/pygobject.git?signed#tag=$pkgver"
  "git+https://gitlab.gnome.org/GNOME/gobject-introspection-tests.git#commit=53e6bc978d5011f22d0a27cca49a94b19816ca7d"
  "git+https://github.com/python/pythoncapi-compat#commit=22811c3f0e69908894d2bd724f572b32667f2141"
)
b2sums=('4d32db25e7281d26bb7ff8459311a9c24f72f64c2fdda0a1aff27462dd5d11f4b46858b2f883b70c36e39205b28c563831525cf0e2898d1c680c7c325ddf23cd'
        '331ab5a17f2f113ea8f95e5c202e0cfca0d37e9d4029a81f352506a8444f45de539d12711dbee8ef3d4f355d9cef9bf281515c558008fd880d7644d1d9fc0356'
        '6ff1699812c68bbfe129906da84cec73102d9f1a83975a13a8325341808a71fc73b75e0a8cb532b68dbb7f174bca6d0fb83d48f834e72e74b28fb71a51a8491b')
validpgpkeys=(
  0EBF782C5D53F7E5FB02A66746BD761F7A49B0EC # Christoph Reiter <reiter.christoph@gmail.com>
  12B7C9847B4AD5787318A831A61779569ADCE5E6 # Arjan Molenaar <gaphor@gmail.com>
)

prepare() {
  cd pygobject
}

build() {
  # Inject subprojects
  export MESON_PACKAGE_CACHE_DIR="$srcdir"

  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:
