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

_realname=pygithub
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.8.1
pkgrel=1
pkgdesc="Use the full Github API v3 (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-pygithub'
  'gentoo: dev-python/pygithub'
  'purl: pkg:pypi/pygithub'
)
msys2_repository_url='https://github.com/PyGithub/PyGithub/'
url='https://pygithub.readthedocs.io/'
msys2_changelog_url='https://pygithub.readthedocs.io/en/stable/changes.html'
license=('spdx:LGPL-3.0' 'spdx:GPL-3.0')
depends=("${MINGW_PACKAGE_PREFIX}-python-pyjwt"
         "${MINGW_PACKAGE_PREFIX}-python-requests"
         "${MINGW_PACKAGE_PREFIX}-python-typing_extensions"
         "${MINGW_PACKAGE_PREFIX}-python-pynacl"
         "${MINGW_PACKAGE_PREFIX}-python-urllib3")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-cryptography"
              "${MINGW_PACKAGE_PREFIX}-python-httpretty"
              "${MINGW_PACKAGE_PREFIX}-python-parameterized")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('341b7c78521cb07324ff670afd1baa2bf5c286f8d9fd302c1798ba594a5400c9')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m pytest || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -vDm644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING"
}
