# 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.31.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=(
  '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=($pkgname-$pkgver.tar.gz::$_url/archive/refs/tags/$pkgver.tar.gz)
sha512sums=('6e3712391fa4b4f40fac0e3ef276fa6093c5264646967f622859743ebdee171145c7b44f7801ed56f7dc8f1c26bb0087c758cdaf836d0f15898d5d3a2a4a4077')
b2sums=('a2ec32c2ff87896b43fa2c51274d48343d791e32ac659f756a64db88bac09f2ff8a9899da2b59b957f050904be168fa3cb86ceb6b0c1e94499942d7cf04bbb92')

build() {
  cd $_name-$pkgver
  SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver 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() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  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
}
