# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>

_name=cbor2
pkgname=python-cbor2
pkgver=5.6.4
pkgrel=1
pkgdesc="Pure Python CBOR (de)serializer with extensive tag support"
arch=(x86_64 aarch64)
url="https://github.com/agronholm/cbor2"
license=(MIT)
depends=(glibc
         python)
makedepends=(python-{build,installer,wheel}
             python-setuptools-scm
             python-toml)
checkdepends=(python-hypothesis
              python-pytest)
source=($url/archive/refs/tags/$pkgver/$_name-$pkgver.tar.gz)
sha512sums=('713e82bfc64d82eeaba7f9a18f9be82ec846f8cb18ec393edffd9108aec5346ca0184b188ffeec2e51343d4c30832640d4dbaaaf5de7dc80618f503502c979e9')
b2sums=('ed6c8945cb6d5abaeaae1d4ebb78379f5ba230e36b8e1c44c7dc0945108b6e4dd00a0213bc73b039df8534a451496652d1fa8bee68e0b01766a80ed08677bd19')

build() {
  cd $_name-$pkgver
  SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver python -m build -wn
}

check() {
  cd $_name-$pkgver
  export PYTHONPATH="build:${PYTHONPATH}"
  pytest -v -c /dev/null tests
}

package() {
  cd $_name-$pkgver
  python -m installer -d "$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 LICENSE.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
}
