# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=python-asttokens
_name=${pkgname#python-}
pkgver=2.4.1
pkgrel=2
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-six')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools-scm'
  'python-wheel'
)
checkdepends=('python-astroid' 'python-pytest')
source=("git+$url.git#tag=v$pkgver")
b2sums=('860f005da2487e3ab34213cfedf1a615a86856143510cbb6567de2700ab34a74ae161f1316e05d8d868839643db7ecd4010d61926de774595e205f1ad0562a1b')

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() {
  cd "$_name"
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  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
}
