# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Chih-Hsuan Yen <yan12125@archlinux.org>
# Contributor: Kyle Keen <keenerd@gmail.com>

pkgname=python-jaraco.collections
_name="${pkgname#python-}"
pkgver=5.1.0
pkgrel=1
pkgdesc="Models and classes to supplement the stdlib 'collections' module."
arch=('any')
url='https://github.com/jaraco/jaraco.collections'
license=('MIT')
depends=('python' 'python-jaraco.text')
makedepends=('python-build' 'python-installer' 'python-setuptools-scm' 'python-wheel')
checkdepends=('python-pytest')
conflicts=('python-jaraco')
replaces=('python-jaraco')
source=("$_name-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha512sums=('6dfb5bf22e55a5148e8c846bf2d3f5a6c628bbe2034b8425153c3978aeff738a9fe00e426e7e2c421827e8a87e5270716d211d9ee42eed786d81e14791cec842')

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

check() {
  local pytest_options=(
    -vv
  )

  cd "$_name"-$pkgver
  python -m pytest "${pytest_options[@]}"
}

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
}

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