# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=aiohttp
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.11.17
pkgrel=1
pkgdesc='HTTP client/server for asyncio (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-aiohttp'
  'purl: pkg:pypi/aiohttp'
  "cpe: cpe:2.3:a:aio-libs_project:aiohttp"
  "cpe: cpe:2.3:a:aiohttp:aiohttp"
  "cpe: cpe:2.3:a:aiohttp_project:aiohttp"
)
msys2_repository_url='https://github.com/aio-libs/aiohttp/'
url='https://docs.aiohttp.org/'
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python-attrs"
         "${MINGW_PACKAGE_PREFIX}-python-multidict"
         "${MINGW_PACKAGE_PREFIX}-python-yarl"
         "${MINGW_PACKAGE_PREFIX}-python-frozenlist"
         "${MINGW_PACKAGE_PREFIX}-python-propcache"
         "${MINGW_PACKAGE_PREFIX}-python-aiohappyeyeballs"
         "${MINGW_PACKAGE_PREFIX}-python-aiosignal")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-freezegun"
"${MINGW_PACKAGE_PREFIX}-python-pytest-cov"
"${MINGW_PACKAGE_PREFIX}-python-pytest-mock"
"${MINGW_PACKAGE_PREFIX}-python-pytest-timeout"
"${MINGW_PACKAGE_PREFIX}-python-pytest-xdist"
"${MINGW_PACKAGE_PREFIX}-python-trustme"
"${MINGW_PACKAGE_PREFIX}-python-async_generator"
"${MINGW_PACKAGE_PREFIX}-python-brotli")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-brotli: for Brotli transfer-encodings support")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('2bf3ff374c3abd7a5c6c8de3ad7ed91e0e89a8b53353314c93766c3add5a208a')

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 -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
