# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-astor
pkgver=0.8.1
pkgrel=10
pkgdesc="Read/rewrite/write Python ASTs"
arch=('any')
license=('BSD-3-Clause')
url="https://astor.rtfd.org/"
depends=('python')
makedepends=('git' 'python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-pytest')
source=("git+https://github.com/berkerpeksag/astor.git#tag=$pkgver"
        "0001-Reduce-huge-int-in-test-Closes-212.patch"
        "0002-Fix-compatibility-with-Python-3.14-mostly.patch")
sha512sums=('ef373524ebdcff8d29d53dbdd1e4844e25bf90c3e808aa6d1c970ab57d069f5561da93ce927b26b2d5e0835b90a79f93bcbdc057fa276805aa56786a0a0a99e2'
            'c7f17984a9e372222707e15542e07f799ce6e55c9494a7b18f897e9ce65ec904d403bdb286e4be090ae3bb3b42bf2bc32f78448a14cf5a6807df8afeba011ea7'
            '36900355e48b3679dfdccc0f6ed311f46c64fb14822951965973583817925f6ac418bb28d74a7f4eb1520a24a446d6950487bfc32610af10c38de1df0094ed9c')

prepare() {
  cd astor
  patch -Np1 -i ../0001-Reduce-huge-int-in-test-Closes-212.patch
  patch -Np1 -i ../0002-Fix-compatibility-with-Python-3.14-mostly.patch
}

build() {
  cd astor
  python -m build --wheel --no-isolation
}

check() {
  cd astor
  # De-select failing test
  # https://github.com/berkerpeksag/astor/issues/146
  pytest '-k not test_convert_stdlib'
}

package() {
  cd astor
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
