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

_realname=yarl
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.22.0
pkgrel=2
pkgdesc='Yet another URL library (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://yarl.aio-libs.org/'
msys2_repository_url='https://github.com/aio-libs/yarl/'
msys2_changelog_url='https://yarl.aio-libs.org/en/latest/changes/'
msys2_references=(
  'archlinux: python-yarl'
  'gentoo: dev-python/yarl'
  'purl: pkg:pypi/yarl'
)
license=('spdx:Apache-2.0')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python-idna"
  "${MINGW_PACKAGE_PREFIX}-python-multidict"
  "${MINGW_PACKAGE_PREFIX}-python-propcache")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
  "${MINGW_PACKAGE_PREFIX}-python-expandvars"
  "${MINGW_PACKAGE_PREFIX}-cython"
  "${MINGW_PACKAGE_PREFIX}-cc")
checkdepends=(
  "${MINGW_PACKAGE_PREFIX}-python-pytest"
  "${MINGW_PACKAGE_PREFIX}-python-pytest-cov")
source=("https://github.com/aio-libs/yarl/archive/v${pkgver}/yarl-${pkgver}.tar.gz")
sha256sums=('d63cfdafde4efd6b1730c600c32c5a8ea6282cf4122924edb5da85014a20275e')

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

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