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

_realname=cliff
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.13.1
pkgrel=1
pkgdesc="Command Line Interface Formulation Framework (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-cliff'
  'gentoo: dev-python/cliff'
  'purl: pkg:pypi/cliff'
)
msys2_repository_url='https://opendev.org/openstack/cliff/'
msys2_documentation_url='https://docs.openstack.org/cliff/latest/'
msys2_issue_tracker_url='https://launchpad.net/python-openstackclient/'
url='https://docs.openstack.org/cliff/latest/'
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python-autopage"
         "${MINGW_PACKAGE_PREFIX}-python-cmd2"
         "${MINGW_PACKAGE_PREFIX}-python-prettytable"
         "${MINGW_PACKAGE_PREFIX}-python-stevedore"
         "${MINGW_PACKAGE_PREFIX}-python-yaml")
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-testrepository"
#              "${MINGW_PACKAGE_PREFIX}-python-mock"
#              "${MINGW_PACKAGE_PREFIX}-python-sphinx"
#              "${MINGW_PACKAGE_PREFIX}-python-oslosphinx"
#              "${MINGW_PACKAGE_PREFIX}-python-testscenarios")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('b79cc0b2c19f6c6e78c82bd923e06785035d77cb0d2a1a483229f0a2836f0ca7')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"

  # Set version for pbr
  export PBR_VERSION=${pkgver}
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

#check() {
#  msg "Python test for ${MSYSTEM}"
#  cd "${srcdir}/python-build-${MSYSTEM}"
#  PYTHON=${MINGW_PREFIX}/bin/python3 \
#     ${MINGW_PREFIX}/bin/python setup.py testr
#}

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