# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=python-pytest-freezer
pkgver=0.4.9
pkgrel=1
pkgdesc='Pytest plugin providing a fixture interface for freezegun'
arch=(any)
url='https://github.com/pytest-dev/pytest-freezer'
license=(MIT)
depends=(
  python
  python-pytest
  python-freezegun
)
makedepends=(
  git
  python-build
  python-installer
  python-flit-core
)
checkdepends=(python-pytest)
source=("$pkgname::git+$url#tag=$pkgver")
sha512sums=('09554a6e529b57d9d59d89723f81481e6e0942bc8b9fabd9abccaaff48eaa944cb2499e08714163ce66b78d9e1cd6fc9d17607cba36881f58403f6bb078820bd')
b2sums=('ea2441aa43a2eeacc47cd6ee2048bc5f5169355d0073251591b2b2142276f5ac774855cd4f7b44f5dba8eab84a314faaae9fb61111e910901017a5ffcaaa30c9')

build() {
  cd "$pkgname"

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

check() {
  cd "$pkgname"

  # install to temporary directory
  python -m installer --destdir="$(pwd)/tmp_install" dist/*.whl
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  PYTHONPATH="$(pwd)/tmp_install$site_packages" pytest -v
}

package() {
  cd "$pkgname"

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

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
