# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

_pkgname=LibCST
pkgname=python-libcst
pkgver=1.4.0
pkgrel=2
pkgdesc="A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree"
arch=('x86_64' 'aarch64')
url='https://github.com/Instagram/LibCST'
license=('MIT')
depends=('glibc' 'gcc-libs' 'python' 'python-pyyaml')
makedepends=('python-build' 'python-installer'
             'python-setuptools-rust' 'python-setuptools-scm' 'python-wheel')
#checkdepends=('python-hypothesis' 'python-hypothesmith')
#source=("https://pypi.io/packages/source/l/libcst/libcst-$pkgver.tar.gz")
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha512sums=('e95b2d30cb0273e5b723cf532f63b7b18f44c7f909a9d03331e0b7b7200bee8b635de4782071fb099609fcc4fb1c81bd5cd7ee3d44de535e2e1ad7b1363d31e0')

#prepare() {
#  cd $_pkgname-$pkgver
#
#  sed -i '/pyre.*start/d' scripts/regenerate-fixtures.py
#  python scripts/regenerate-fixtures.py
#}

build() {
  cd $_pkgname-$pkgver

  SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver python -m build --wheel --no-isolation
}

#check() {
#  cd $_pkgname-$pkgver
#
#  python -m venv --system-site-packages testenv
#  python -m installer --prefix=testenv dist/*.whl
#
#  testenv/bin/python -m libcst.tests
#}

package() {
  cd $_pkgname-$pkgver

  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/

  # remove tests
  rm -rfv "$pkgdir"/usr/lib/python*/site-packages/libcst/tests/
  rm -rfv "$pkgdir"/usr/lib/python*/site-packages/libcst/**/tests/
}

# vim:set ts=2 sw=2 et:
