# Maintainer:
# Contributor: Eli Schwartz <eschwartz@archlinux.org>

_name=wheezy.template
pkgname=python-wheezy-template
pkgver=3.1.0
pkgrel=5
pkgdesc="lightweight template library"
arch=(x86_64 aarch64)
url="https://github.com/akornatskyy/wheezy.template"
license=(MIT)
depends=(python)
makedepends=(
  cython
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(python-pytest)
# NOTE: no tests in pypi sdist tarball
# source=(https://files.pythonhosted.org/packages/source/${_name:0:1}/$_name/$_name-$pkgver.tar.gz)
source=(
  $pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz
  $pkgname-3.1.0-python3.11.patch  # https://github.com/akornatskyy/wheezy.template/issues/68
  fix-markup-types.patch::https://github.com/akornatskyy/wheezy.template/commit/055a227b1b5885437f04480082eefd22e23dca24.patch
)
sha256sums=('a75692c8bc4aeb750a378192fe094f6c28901526c6ca754fa92f3783cdd7abcd'
            '4a77d24ec88623fac9729b5f3d4eeade8e6bbb0c14710ff229844dd4d7c3e26a'
            '55e0e206eea6f0a46ab7ffe878f0a84e5430a27d9191e94b111f58ab6cfeda4f')
b2sums=('6cbaa6e5656a0b3bf417ed500770c97f2207f97822ccdf624c87cb0f3c0d2fa3b1a2269641325c6d6138568aeff3bcc417e6e4896186e2fe7c1b31a15e2d7365'
        '2d38b102c63459e1561b2864b954cce1c706f5163b43d2f860f09a33d99cf50ce2729303eb91da04238484595502b1a85ef39d114b695fc27d6261502804b3bb'
        '8ba9a7c4280e4c39f1281071de853a63b187c09ca350b9ae4c90db4c832f543940923c0ee7fb8f1308c58b5bc42c9539c889415ddcf81d5e9cc4c9430aef3d27')

prepare() {
  patch -Np1 -d $_name-$pkgver -i ../$pkgname-3.1.0-python3.11.patch
  patch -Np1 -d $_name-$pkgver -i ../fix-markup-types.patch
}

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

check() {
  cd $_name-$pkgver
  export PYTHONPATH="$PWD/src:$PYTHONPATH"
  pytest --import-mode=importlib
}

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