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

pkgname=python-rapidjson
pkgver=1.16
pkgrel=2
pkgdesc="Python wrapper around rapidjson"
arch=('x86_64' 'aarch64')
url="https://pypi.python.org/pypi/python-rapidjson"
license=('MIT')
depends=('python')
makedepends=('python-setuptools' 'python-build' 'python-installer' 'python-wheel' 'rapidjson')
checkdepends=('python-pytest' 'python-pytest-benchmark' 'python-pytz')
source=("https://pypi.io/packages/source/p/python-rapidjson/python-rapidjson-$pkgver.tar.gz")
sha512sums=('234ef5ea574213e5725db2f196fee30ee8de1b23c956b036f8ab109112ac815fd1bc60fffb0addad32be15d405116ce813e97f595ff5a660c505ea05bc1e1ca3')

prepare() {
  #rm -r python-rapidjson-$pkgver/rapidjson
  #sed -i 's/if not os.path.isdir/if os.path.isdir/' python-rapidjson-$pkgver/setup.py
  # Shared rapidjson fails tests.
  :
}

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

check() {
  cd python-rapidjson-$pkgver
  local python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-cpython-$python_version" pytest --ignore benchmarks/
}

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