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

_realname='pygithub'
pkgbase="mingw-w64-python-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-python-${_realname}"
pkgver=2.10.0
pkgrel=2
pkgdesc='Use the full Github API v3 (mingw-w64)'
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://pygithub.readthedocs.io/'
msys2_repository_url='https://github.com/PyGithub/PyGithub/'
msys2_changelog_url='https://pygithub.readthedocs.io/en/stable/changes.html'
msys2_references=(
  'archlinux: python-pygithub'
  'gentoo: dev-python/pygithub'
  'purl: pkg:pypi/pygithub'
)
license=('spdx:LGPL-3.0' 'spdx:GPL-3.0')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python"
  "${MINGW_PACKAGE_PREFIX}-python-pyjwt"
  "${MINGW_PACKAGE_PREFIX}-python-pynacl"
  "${MINGW_PACKAGE_PREFIX}-python-requests"
  "${MINGW_PACKAGE_PREFIX}-python-typing_extensions"
  "${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-cryptography"
  "${MINGW_PACKAGE_PREFIX}-python-httpretty"
  "${MINGW_PACKAGE_PREFIX}-python-pytest"
  "${MINGW_PACKAGE_PREFIX}-python-responses"
)
source=(
  "https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz"
)
sha256sums=('90ff24ef1cd1bd57124c2a3869cafee9d7b066909129ecdaba2c2d1903bc118d')

build() {
  cp -r "${_realname}-${pkgver}" "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "build-${MSYSTEM}"

  python -m pytest
}

package() {
  cd "build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix="${MINGW_PREFIX}" --destdir="${pkgdir}" dist/*.whl

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