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

_realname=stestr
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.2.0
pkgrel=1
pkgdesc="A test runner runner similar to testrepository (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-stestr'
  'purl: pkg:pypi/stestr'
)
url='https://stestr.readthedocs.io/'
msys2_repository_url='https://github.com/mtreinish/stestr/'
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-cliff"
         "${MINGW_PACKAGE_PREFIX}-python-extras"
         "${MINGW_PACKAGE_PREFIX}-python-fixtures"
         "${MINGW_PACKAGE_PREFIX}-python-pbr"
         "${MINGW_PACKAGE_PREFIX}-python-subunit"
         "${MINGW_PACKAGE_PREFIX}-python-testtools"
         "${MINGW_PACKAGE_PREFIX}-python-tomlkit"
         "${MINGW_PACKAGE_PREFIX}-python-voluptuous"
         "${MINGW_PACKAGE_PREFIX}-python-yaml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-flit-core"
             "${MINGW_PACKAGE_PREFIX}-python-installer")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha512sums=('2d870604f671b720bfa7ac21d58b5beb56aab2fe4e70e99c8f332ed0081c0c86e791eeb92d4477b6dafaed50ffa17a0ac8e776bd35713fa5a1b0785803a27ba8')

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