# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: eolianoe <eolianoe At GoogleMAIL DoT com>
# Contributor: Étienne Deparis <etienne [at] depar.is>
# Contributor: Patrice Peterson <runiq at archlinux dot us>
# Contributor: Patrick Burroughs <celticmadman at gmail dot com>

pkgname=python-tzlocal
_name=${pkgname#python-}
pkgver=5.3.1
pkgrel=1
epoch=1
pkgdesc="Tzinfo object for the local timezone"
arch=('any')
url=https://github.com/regebro/tzlocal
license=('MIT')
depends=('python')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=(
  'python-pytest'
  'python-pytest-mock'
)
source=("git+$url.git#tag=$pkgver")
b2sums=('c67272ea16b95fc8c479f5033072bdf06f6ecb1960869f0afda795d7a77f94521e4fc9765a07d705fbbb830da6771fded7d18b0bb4bda56bb987672421f18188')

prepare() {
  cd "$_name"
  # fix symlink, required for test: https://github.com/regebro/tzlocal/issues/53
  cd tests/test_data/symlink_localtime/etc
  ln -sfv ../usr/share/zoneinfo/Africa/Harare localtime
}

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

check() {
  cd "$_name"
  export PYTHONPATH="build:$PYTHONPATH"
  pytest -v
}

package() {
  cd "$_name"
  python -m installer --destdir="$pkgdir" dist/*.whl
  # docs
  install -vDm 644 {CHANGES.txt,README.rst} \
    -t "$pkgdir/usr/share/doc/$_name"

  # 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.txt \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.txt
}

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