# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=tox
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.30.3
pkgrel=1
pkgdesc="Python virtualenv management and testing tool (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-tox'
  'gentoo: dev-python/tox'
  'purl: pkg:pypi/tox'
)
msys2_repository_url='https://github.com/tox-dev/tox/'
url='https://tox.wiki/'
msys2_changelog_url='https://tox.wiki/en/stable/changelog.html'
license=('spdx:MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling"
             "${MINGW_PACKAGE_PREFIX}-python-hatch-vcs")
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-cachetools"
         "${MINGW_PACKAGE_PREFIX}-python-chardet"
         "${MINGW_PACKAGE_PREFIX}-python-colorama"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-platformdirs"
         "${MINGW_PACKAGE_PREFIX}-python-pluggy"
         "${MINGW_PACKAGE_PREFIX}-python-pyproject-api"
         "${MINGW_PACKAGE_PREFIX}-python-virtualenv"
         "${MINGW_PACKAGE_PREFIX}-python-filelock")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('f3dd0735f1cd4e8fbea5a3661b77f517456b5f0031a6256432533900e34b90bf')

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

#This hangs when I try this.
#check() {
#  cd "${srcdir}/python-build-${MSYSTEM}"
#  msg "Python build for ${MSYSTEM}"
#  ${MINGW_PREFIX}/bin/virtualenv "$srcdir/pyvenv" --system-site-packages
#  . "$srcdir/pyvenv/bin/activate"
#  ${MINGW_PREFIX}/bin/python setup.py install
#  ${MINGW_PREFIX}/bin/python setup.py pytest
#
#}

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