# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=aiormq
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=6.9.3
pkgrel=1
pkgdesc="Pure python AMQP 0.9.1 asynchronous client library (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/mosquito/aiormq/'
msys2_repository_url='https://github.com/mosquito/aiormq'
msys2_references=(
  'anitya: 35319'
  'aur: python-aiormq'
  'purl: pkg:pypi/aiormq'
)
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-pamqp"
         "${MINGW_PACKAGE_PREFIX}-python-yarl")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-poetry-core"
             "${MINGW_PACKAGE_PREFIX}-python-uv-build"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz"
        "${msys2_repository_url}/raw/refs/tags/${pkgver}/COPYING")
sha256sums=('39f57d85650267aebefca162a523e9e000db02468d4fceccb3c5399f378ddabe'
            'f597f46bb7c16287b809e80c197e74ecb273c2a5fafc137b496095a168f5aa54')

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

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

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

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

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