# Maintainer: 

pkgname=python-sphinx-notfound-page
_pyname=${pkgname/python-/}
pkgver=1.1.0
pkgrel=1
pkgdesc='Create a custom 404 page with absolute URLs hardcoded'
url='https://github.com/readthedocs/sphinx-notfound-page'
arch=(any)
license=(MIT)
depends=(python
         python-docutils
         python-sphinx)
makedepends=(git
             python-build
             python-flit-core
             python-installer)
checkdepends=(python-pytest)
source=(git+https://github.com/readthedocs/sphinx-notfound-page#tag=$pkgver)
sha512sums=('09275ace82f302748fe1d264601c6f1ac78b8447e50c28930902dc795fc37a88ac3f8ee4304024285e20af881e0ded6bd730b432650dfcf16ab0618ec5dfb72f')

prepare() {
  cd $_pyname
  git cherry-pick -n 8af414e0f76dddd64143090a7eb9ff9d3f1de2d1 # Fix tests
}

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

check() {
  cd $_pyname
  python -m installer --destdir=tmp-install dist/*.whl
  PYTHONPATH="$PWD"/tmp-install`python -c "import site; print(site.getsitepackages()[0])"` \
  pytest -v
}

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