# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

_name=pytz_deprecation_shim
pkgname=python-pytz-deprecation-shim
pkgver=0.1.0.post0
pkgrel=6
pkgdesc='Shims to make deprecation of pytz easier'
arch=(any)
url=https://github.com/pganssle/pytz-deprecation-shim
license=('Apache')
depends=('python-tzdata')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-hypothesis' 'python-pytest' 'python-pytz')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz")
sha256sums=('af097bae1b616dde5c5744441e2ddc69e74dfdcb0c263129610d85b87445a59d')
b2sums=('a6d186ca6fff17a3fb787ad6164fcf45fbac272e6123491a6822699cf54a115c9941f2b1ee3d227f531a0ab1d11846300dc24974611cc1671c77405606704754')

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

check() {
  cd $_name-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/$_name-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
