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

_name=pure_eval
pkgname=python-pure-eval
pkgver=0.2.2
pkgrel=4
pkgdesc='Safely evaluate AST nodes without side effects'
arch=('any')
url=https://github.com/alexmojaki/pure_eval
license=('MIT')
depends=('python')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools-scm'
  'python-wheel'
)
checkdepends=('python-pytest')
source=("git+$url.git#tag=v$pkgver")
b2sums=('7c6948b6fad8f6fd7070ee830ca44dca35a28239c1708ab33c25f3d79847accc3a6efc422f2a7bca33b4490a2222fa8b9053057786c407ed3d364d9cfaa849fe')

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.txt \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt
}
