# Maintainer: Sarah Ottinger

_realname=pytest-timeout
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.3.0
pkgrel=1
pkgdesc='py.test plugin to abort hanging tests (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
msys2_references=(
  'archlinux: python-pytest-timeout'
  'pypi: pytest-timeout'
)
url='https://github.com/pytest-dev/pytest-timeout'
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
source=("https://github.com/pytest-dev/pytest-timeout/archive/$pkgver/${_realname}-$pkgver.tar.gz")
sha512sums=('be2f706bac5375f48c9fd92d420cccb118b0ea2aa9bbc6eb7bffef4af624d682de99b52dd106c1cbb8b5ecffcbf25ff4ab3c8e121e92d7f429e8784ed79b5aa0')

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