# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>

_name=optree
pkgname=python-"${_name}"
pkgver=0.18.0
pkgrel=1
pkgdesc="Optimized PyTree Utilities"
arch=(any)
url="https://github.com/metaopt/optree"
license=(Apache-2.0)
depends=(python python-typing_extensions)
makedepends=(python-setuptools python-build python-installer python-wheel cmake gcc pybind11 python-cmake-build-extension)
source=("$_name-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha512sums=('8bcfc8541ea5d886dfb6cde7153e2e570934fbd9944546ac28ab653f1137d179bc44272a486b8e33ba9a800115a683b506d54e3670ede233c6b0855741b10819')
b2sums=('24efa7f6c377c7c1cdb98ed73d08b0b33e9497026a0aa233b8a301475138ea292a4d7ed7a0799215fe280d1aa66f912f4321938f48324b64e94969fbe56ad5c5')

prepare() {
	cd "$_name-$pkgver"
	# Remove cmake version check, which is broken due to our current version string
	# "4.3.0-dirty" not being accepted. Our cmake version is compatible.
	sed -i '168,169d' setup.py
}

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

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