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

pkgname=python-profilestats
_name="${pkgname#python-}"
pkgver=2.0
pkgrel=15
pkgdesc="Decorator for profiling individual functions and converting profiling data to the kcachegrind/qcachegrind format."
arch=('any')
license=(LicenseRef-Unknown-BSD)
url="https://github.com/hannosch/profilestats"
depends=(
  python
  pyprof2calltree
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
source=(
  "https://github.com/hannosch/profilestats/archive/$pkgver/$pkgname-$pkgver.tar.gz"
  $pkgname-2.0-remove_setuptools.patch
)
sha512sums=('918d23df8f076dc6b0be0dc70e8899f638d6a911472193624e6a7594a1b1c82975f0090dddbcdadcb0c6a0c11b2bb6f22fad11561322cdf962c719854663b23a'
            '5622b357f8a1efb506de29816396b8d24e054e40c2b7cc264d8452a98dee0171bad5c56c6e7212342abff2ce6df387635a2fca7b0611636da439c134f54f9970')

prepare() {
  patch -Np1 -d $_name-$pkgver -i ../$pkgname-2.0-remove_setuptools.patch
  echo "Project claims BSD, but actually no license: https://github.com/hannosch/profilestats/issues/5" > LICENSE
}

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

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