# Contributor: Dirk Stolle

_realname=httpbin
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.10.2
pkgrel=1
pkgdesc="HTTP Request and Response Service (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64')
url='https://github.com/psf/httpbin'
msys2_references=(
  'archlinux: httpbin'
  'gentoo: dev-python/httpbin'
  'purl: pkg:pypi/httpbin'
)
license=('spdx:MIT', 'spdx:ISC')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-brotlicffi"
         "${MINGW_PACKAGE_PREFIX}-python-decorator"
         "${MINGW_PACKAGE_PREFIX}-python-flasgger"
         "${MINGW_PACKAGE_PREFIX}-python-flask"
         "${MINGW_PACKAGE_PREFIX}-python-greenlet"
         "${MINGW_PACKAGE_PREFIX}-python-werkzeug")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('632148698261c8684ea2d2b624cdea845b402b1fe91736e89df886408c6317a9')

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

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

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

  python -m pytest
}

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

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

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
  install -Dm644 LICENSE.ISC "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.ISC"
  install -Dm644 LICENSE.MIT "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.MIT"
}
