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

_realname=stestr
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.2.1
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=('bba00836b3235f9ac220c2675d365954b1d48aaa238acc6192d294000cb34dc2417568186424708a05c7e3c07a5b7ddf8a8cf4741d568f7e8fc3765de23229c2')

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