# Maintainer: ciciwu <doudingding213@gmail.com>

_realname=qasync
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.27.1
pkgrel=2
pkgdesc='Python library for using asyncio in Qt-based applications. (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/CabbageDevelopment/qasync"
msys2_references=(
  'purl: pkg:pypi/qasync'
)
license=('spdx:BSD-2-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-poetry-core")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-pyqt5"
            "${MINGW_PACKAGE_PREFIX}-python-pyqt6"
            "${MINGW_PACKAGE_PREFIX}-pyside2"
            "${MINGW_PACKAGE_PREFIX}-pyside6")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('8dc768fd1ee5de1044c7c305eccf2d39d24d87803ea71189d4024fb475f4985f')

prepare() {
  cd "${srcdir}"

  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

#check() {
#  cd "${srcdir}/python-build-${MSYSTEM}"
#  PYTHONPATH=. ${MINGW_PREFIX}/bin/pytest .
#}

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"
}

