# Maintainer: Xeonacid <h.dwwwwww@gmail.com>

_name=untokenize
pkgname=python-${_name}
pkgver=0.1.1
pkgrel=3
pkgdesc="Transforms tokens into original source code (while preserving whitespace)"
arch=(any)
url="https://github.com/myint/${_name}"
license=(MIT)
depends=(python)
makedepends=(git python-build python-installer python-setuptools python-wheel)
source=(git+$url.git#tag=v${pkgver}
        # unavailable in 0.1.1 release
        https://github.com/myint/untokenize/raw/137ae8b8ec03e94444325172451ba2104c8ee05e/LICENSE
        support-python-3.14.patch::https://github.com/myint/untokenize/pull/5.diff)
sha512sums=('a55d16558619022d293a047f6f1710f201b410e56a2a4008277244b55aed481365b344cdf572ae1f3733d49a4b392e65e9fe446d2d41f89922a6b8988f2a3922'
            '8f7e9200323613d984c3ce3a2f3d14371c0f93f48e7e31bd1baf238d843d1fa47058048e949b57125640baf92a0c402bd4700a19ea9f922e90e00a4a73fdef2e'
            '95b76ef8c488e8b5c144ae55be25f96efa32783aa356a8ae1cc71989672b28d44010dbb14f8ce8d63a3273ba7ccc28a87a2f50ff1bfef98492936adeef5b46d4')

prepare() {
  cd $_name
  # Fix Python 3.14
  patch -Np1 -i ../support-python-3.14.patch
}

build() {
  cd $_name
  python -m build --wheel --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 test_untokenize.py
}

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