# Maintainer: Jelle van der Waa <jelle@vdwaa.nl>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: lilydjwg <lilydjwg@gmail.com>

# As of 2.9.0, upstream is tagging on GitHub and commits are signed with the
# generic GH key, not the project member's own keys. Commit pinning and key
# checking is disabled until there is something of substace to check.

# _commit=db9d018944c41ddc740015cf5f64717c2ba64a5c

pkgname=python-dateutil
pkgver=2.9.0
pkgrel=6
pkgdesc="Provides powerful extensions to the standard datetime module"
arch=(any)
license=(BSD-3-Clause Apache-2.0)
url="https://github.com/dateutil/dateutil"
depends=(python-six)
makedepends=(python-{build,installer,wheel}
             python-setuptools-scm
             python-six git)
checkdepends=(python-freezegun
              python-hypothesis
              python-pytest)
# source=("git+$url.git?signed#commit=${_commit:-$pkgver}")
source=("git+$url.git#commit=${_commit:-$pkgver}")
sha256sums=('db84e1759eb51252204597504409cafee32ea9a9616e64d82d8ec769048ff00e')
# validpgpkeys=('5DE3E0509C47EA3CF04A42D34AEE18F83AFDEB23') # Mario Corchero <mariocj89@gmail.com>

prepare() {
  cd dateutil
  # Download the tarball required for running tests
  PYTHONPATH=src python updatezinfo.py
}

build() {
  cd dateutil
  python -m build -wn
}

check() {
  cd dateutil
  # https://github.com/pytest-dev/pytest/issues/5678
  PYTHONPATH=src pytest -W ignore::pytest.PytestUnknownMarkWarning .
}

package() {
  cd dateutil
  python -m installer -d "$pkgdir" dist/*.whl
  install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE

  # HACK: package_date is not installed via PEP517 while it should
  # https://github.com/dateutil/dateutil/blob/1ae807774053c071acc9e7d3d27778fba0a7773e/setup.cfg#L52
  local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  install -Dm0644 -t "$pkgdir/usr/lib/python${python_version}/site-packages/dateutil/zoneinfo/" \
  	"${srcdir}/dateutil/src/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz"
}
