# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=python-asttokens
_name=${pkgname#python-}
pkgver=3.0.0
pkgrel=1
pkgdesc='Get the currently executing AST node of a frame, and other information'
arch=(any)
url=https://github.com/gristlabs/asttokens
license=(Apache-2.0)
depends=(python)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools-scm
  python-wheel
)
checkdepends=(
  python-astroid
  python-pytest
)
source=("git+$url.git#tag=v$pkgver")
b2sums=('553fb87e6a611e954d67a7312d8df2d5c6ca152368579b5107e36ee9b351c901ca295c0ab6e0cf05a74e35f06a544d32f3969ef8dfdf1f3352b9d614e35d37bf')

build() {
  cd "$_name"
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "$_name"
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest
}

package() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/"$_name"-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

  cd "$_name"
  python -m installer --destdir="$pkgdir" dist/*.whl
}
