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

_realname=debtcollector
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.0.0
pkgrel=2
pkgdesc="A collection of Python deprecation patterns and strategies that help you collect your technical debt in a non-destructive manner (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://docs.openstack.org/developer/debtcollector'
msys2_repository_url='https://opendev.org/openstack/debtcollector'
msys2_changelog_url='https://docs.openstack.org/releasenotes/debtcollector/'
msys2_issue_tracker_url='https://bugs.launchpad.net/debtcollector'
msys2_references=(
  'purl: pkg:pypi/debtcollector'
)
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-wrapt")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-pbr"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-stestr")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha512sums=('92072dbe27b09fe9bccf2fe7d27f29742bfa50d19dab60ce5e4b442833aff3dda6f0dd9f72b7a2d3ce580a78d1480e03353d8f9b0e43b59575b979a20945ee26')

build() {
  # for python-pbr
  export PBR_VERSION=${pkgver}

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