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

_realname=subunit
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.4.6
pkgrel=1
pkgdesc="Python implementation of subunit test streaming protocol (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://launchpad.net/subunit'
msys2_repository_url='https://github.com/testing-cabal/subunit'
msys2_changelog_url='https://github.com/testing-cabal/subunit/blob/master/NEWS'
msys2_references=(
  'archlinux: python-subunit'
  'purl: pkg:pypi/python-subunit'
)
license=('spdx:Apache-2.0 OR BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-iso8601"
         "${MINGW_PACKAGE_PREFIX}-python-pyaml"
         "${MINGW_PACKAGE_PREFIX}-python-testtools")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-fixtures"
              "${MINGW_PACKAGE_PREFIX}-python-hypothesis"
              "${MINGW_PACKAGE_PREFIX}-python-testscenarios")
options=('!strip')
source=("https://pypi.io/packages/source/p/python-subunit/python_subunit-${pkgver}.tar.gz")
sha512sums=('96381dd063c5da07c31df69b306cb31d8aacaf9c35651d12ab3e86fc3816222369f0fb6e5ac5d6747f5fa3a1963f4d29eba3d70c3717d455e900b5a767c64ac8')

build() {
  cp -r "python_${_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}"
  PYTHONPATH="$PWD/build/lib" python -m testtools.run subunit.test_suite || warning "Tests failed"
}

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