# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pygobject
pkgbase=mingw-w64-python2-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-gobject")
pkgver=3.34.0
pkgrel=4
pkgdesc="Python 2 bindings for GLib/GObject/GIO/GTK+ (mingw-w64)"
arch=(any)
url="https://pygobject.readthedocs.io"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-python2-cairo"
         "${MINGW_PACKAGE_PREFIX}-libffi"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection-runtime")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
source=(https://download.gnome.org/sources/pygobject/${pkgver%.*}/${_realname}-${pkgver}.tar.xz)
sha256sums=('87e2c9aa785f352ef111dcc5f63df9b85cf6e05e52ff04f803ffbebdacf5271a')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # --no-compile because older packages didn't install .pyc and adding them
  # would lead to upgrade conflicts
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --no-compile
  rm -Rf "${pkgdir}${MINGW_PREFIX}"/{include,lib/pkgconfig}
}