# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=tqdm
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.67.1
pkgrel=1
pkgdesc='Fast, Extensible Progress Meter (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://tqdm.github.io/"
msys2_references=(
  'archlinux: python-tqdm'
  'purl: pkg:pypi/tqdm'
)
msys2_repository_url='https://github.com/tqdm/tqdm'
license=('spdx:MPL-2.0 AND MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-colorama")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-asyncio"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-timeout"
              "${MINGW_PACKAGE_PREFIX}-python-pandas"
              "${MINGW_PACKAGE_PREFIX}-python-numpy")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm"
             "${MINGW_PACKAGE_PREFIX}-python-toml")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m pytest || 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 LICENCE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENCE"
}
