# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=pytest-cov
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=7.0.0
pkgrel=2
pkgdesc="py.test plugin for coverage reporting with support for both centralised and distributed testing, including subprocesses and multiprocessing (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/pytest-dev/pytest-cov'
msys2_changelog_url='https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst'
msys2_references=(
  'archlinux: python-pytest-cov'
  'gentoo: dev-python/pytest-cov'
  'purl: pkg:pypi/pytest-cov'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-coverage"
         "${MINGW_PACKAGE_PREFIX}-python-pluggy"
         "${MINGW_PACKAGE_PREFIX}-python-pytest")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling"
             "${MINGW_PACKAGE_PREFIX}-python-hatch-fancy-pypi-readme"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-virtualenv"
#              "${MINGW_PACKAGE_PREFIX}-python-process-tests"
#              "${MINGW_PACKAGE_PREFIX}-python-pytest-cache"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-xdist"
#              "${MINGW_PACKAGE_PREFIX}-python-fields"
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname/-/_}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('33c97eda2e049a0c5298e91f519302a1334c26ac65c1a483d6206fd458361af1')

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
}

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