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

_realname=stestr
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=4.1.0
pkgrel=1
pkgdesc="A test runner runner similar to testrepository (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
msys2_references=(
  'archlinux: python-stestr'
  '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-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha512sums=('77287ffdfe59042c4d189aa6c662df4357633d3a134ea60a4533b5b8b1b433ffd6f265a430977da175f242cc1c8e8514f876a486cc900a436cf93ab629fe7b7d')

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