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

_realname=pygithub
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.54.1
pkgrel=1
pkgdesc="Use the full Github API v3 (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/PyGithub/PyGithub/"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-python-deprecated"
         "${MINGW_PACKAGE_PREFIX}-python-pyjwt"
         "${MINGW_PACKAGE_PREFIX}-python-requests")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-cryptography"
              "${MINGW_PACKAGE_PREFIX}-python-httpretty"
              "${MINGW_PACKAGE_PREFIX}-python-parameterized")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/PyGithub/PyGithub/archive/v${pkgver}.tar.gz")
sha256sums=('40e6b59cda272e0094d6044efb60b14f0c3b94eba006c9f360f6f3e338a478ed')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${CARCH} | true
  cp -r "PyGithub-${pkgver}" "python-build-${CARCH}"
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python -m pytest
}

build() {
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}
