# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=python-ujson
_pkgname=ultrajson
pkgver=5.9.0
pkgrel=1
pkgdesc="Ultra fast JSON encoder and decoder for Python"
url="https://github.com/ultrajson/ultrajson"
arch=('x86_64' 'aarch64')
license=('BSD')
depends=('python')
makedepends=(python-setuptools-scm python-wheel python-build python-installer)
checkdepends=('python-six' 'python-pytest')
source=(https://github.com/ultrajson/ultrajson/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('191d717dbb7dfb6f4d83cfd29c15d9e69d48f44c9587c4a0aed73a5c1294ba78f7aad1d1ef894b381722d1f193f4c96870e58361e67e661aec7490465b78aa98')
b2sums=('ff25ecb8c823c2c84442d74191c8c736eea054e3f84aa99464df85d7c569b19ab77af5aa67f9d4c77f3f3444b24c569faf16aca54f41c5281242825de7783876')

export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver

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

check() {
  cd ${_pkgname}-${pkgver}
  local PYTHONVERSION="$(python -c 'import sys; print("{}{}".format(sys.version_info.major, sys.version_info.minor))')"
  PYTHONPATH="build/lib.linux-${CARCH}-cpython-${PYTHONVERSION}" pytest
}

package() {
  cd ${_pkgname}-${pkgver}
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
