# Maintainer:
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Thomas Weißschuh <thomas t-8ch.de>
# Contributor: George Brooke <george+arch.aur@george-brooke.co.uk>
# Contributor: Sebastian Wiesner <lunaryorn googlemail com>

pkgname=python-tox
_name="${pkgname#python-}"
pkgver=4.33.0
pkgrel=1
pkgdesc='Python virtualenv management and testing tool'
arch=('any')
url='https://tox.readthedocs.io'
_url="https://github.com/tox-dev/tox"
license=(MIT)
depends=(
  'python'
  'python-cachetools'
  'python-chardet'
  'python-colorama'
  'python-filelock'
  'python-packaging'
  'python-platformdirs'
  'python-pluggy'
  'python-pyproject-api'
  'python-virtualenv'
)
makedepends=(
  'git'
  'python-build'
  'python-hatch-vcs'
  'python-hatchling'
  'python-installer'
)
checkdepends=(
  # 'python-devpi-process'  # NOTE: pulls in devpi-{client,server}
  'python-diff-cover'
  'python-distlib'
  'python-flaky'
  'python-pdm-backend'
  'python-psutil'
  'python-pytest'
  'python-pytest-mock'
  'python-pytest-xdist'
  'python-re-assert'
  'python-setuptools'
  'python-time-machine'
  'python-wheel'
)
optdepends=(
  'python-pytest: for pytest plugin to test tox and its plugins'
  'python-pytest-mock: for pytest plugin to test tox and its plugins'
  'python-re-assert: for pytest plugin to test tox and its plugins'
)
source=("git+$_url.git#tag=$pkgver")
sha512sums=('ec5618040ff5f70da10f8d2b216f178abba950ca09a192ebd40d6c19bf5d1215472ad3e850b5635331f02a2c74cf07c849757c858c10c36c5d0b28a01c058603')

build() {
  cd $_name
  python -m build --wheel --no-isolation
}

# NOTE: needs python-devpi-process to be packaged.
# check() {
#   local pytest_options=(
#     -vv
#   )

#   cd $_name-$pkgver
#   PYTHONPATH=src pytest "${pytest_options[@]}"
# }

package() {
  cd $_name
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  # add legacy symlink
  ln -sv tox "$pkgdir"/usr/bin/tox3
}
