# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

_pkgname=sphinx-theme-builder
pkgname=python-$_pkgname
pkgver=0.2.0b2
pkgrel=9
pkgdesc='Python build backend for Sphinx themes'
arch=('any')
url='https://github.com/pradyunsg/sphinx-theme-builder'
license=('MIT')
depends=(
  'python'
  'python-nodeenv'
  'python-packaging'
  'python-pyproject-metadata'
  'python-rich'
  'python-setuptools'
)
optdepends=(
  'python-build: CLI'
  'python-click: CLI'
  'python-sphinx-autobuild: CLI'
)
makedepends=(
  'python-build'
  'python-flit-core'
  'python-installer'
)
checkdepends=(
  'python-click'
  'python-pytest'
  'python-sphinx-autobuild'
)
source=("$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz"
         https://github.com/pradyunsg/sphinx-theme-builder/commit/bb78c8c8.patch
         https://github.com/pradyunsg/sphinx-theme-builder/commit/adeb3750.patch)
sha512sums=('9900812cbb91a2fae666c010caef0fc2d250ff7ef8ae7b0105c72cee678e4be49784530c49c43d0260e22882ca7b89d4dd83da0c5a59cf3f944647f84e9fd6bf'
            '9a742294c98dd0c399b6a01abc652904e65c969185181a909c627475ea0b15849657f51a996aef9e903d228f0866f157eee56e7b4d9985d90d4eb520663182ae'
            '132e11851d9bfd41f721742764ea801afd4dc604274ca236b3f2a77079e0a47d26eac598beae5dc5cee81387c028604d7e4b07594e9a9e48fcd9f3a063305a2b')

prepare() {
  cd $_pkgname-$pkgver
  patch -p1 -i ../bb78c8c8.patch # Python 3.14 support
  patch -p1 -i ../adeb3750.patch
}

build() {
  cd $_pkgname-$pkgver

  python -m build --wheel --no-isolation
}

check() {
  cd $_pkgname-$pkgver

  PYTHONPATH=src pytest
}

package() {
  cd $_pkgname-$pkgver

  python -m installer --destdir="$pkgdir" dist/*.whl

  install -Dm 644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim:set ts=2 sw=2 et:
