# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-commentjson
pkgver=0.9.0
pkgrel=8
pkgdesc="Add Python and JavaScript style comments in your JSON files"
url="https://github.com/vaidik/commentjson"
license=('MIT')
arch=(any)
depends=('python-lark-parser')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-tests' 'python-six')
source=("$pkgname-$pkgver.tar.gz::https://github.com/vaidik/commentjson/archive/v$pkgver.tar.gz"
        $pkgname-rename-lark.patch::https://github.com/vaidik/commentjson/pull/52.patch
	python3-12-test-infinity-skip.patch)
sha512sums=('cd3d28adecbc445ed3faed7847c65a23829f408cf8aa3fa85544a0f0cf9fa5544b8aff560725cf51921f249123daf9ce9953069e99ca64a312bb4bff652512fe'
            'c00bce5471e912c7a2e0a4db2e96329dd4720b5f6813957bd5e0298ec5fe42ea362fcf0047b7a41e17aeab802bf36ef14e1b30826d87646c104f5f39002356ef'
            'ff442f4bf916703a4231607d8b79f16d71e8b03665deb9431f438edce12075eb1cc784413bdfd23e580e149c8f150cbe8ea137b3b1e6d046d83204e29264c470')

prepare() {
  cd commentjson-$pkgver
  patch -p1 -i ../$pkgname-rename-lark.patch
  patch -p1 -i ../python3-12-test-infinity-skip.patch
}

build() {
  cd commentjson-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd commentjson-$pkgver
  python -m unittest discover "commentjson.tests"
}

package() {
  cd commentjson-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -Dm644 LICENSE.rst -t "$pkgdir"/usr/share/licenses/$pkgname/
}
