# Maintainer: @naveen521kk on Github, Naveen M K <naveen521kk@gmail.com>

_pyname=click-default-group
_realname=click-default-group
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.2.2
pkgrel=1
pkgdesc='Extends click.Group to invoke a command without explicit subcommand name (mingw-w64)'
arch=('any')
url="https://github.com/sublee/click-default-group/"
license=('BSD')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
checkdepends=(
  "${MINGW_PACKAGE_PREFIX}-python-pytest"
)
source=("${_pyname}-${pkgver}.tar.gz::https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('d9560e8e8dfa44b3562fbc9425042a0fd6d21956fcc2db0077f63f34253ab904')

prepare() {
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_pyname//_/-}-$pkgver" "python-build-${CARCH}"
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  pytest
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
  --root="${pkgdir}" --optimize=1 --skip-build
}
