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

pkgname=python-pkg_resources
pkgver=81.0.0
pkgrel=1
pkgdesc='Temporary stub of pkg_resources for Arch Linux'
arch=(any)
url='https://gitlab.archlinux.org/grawlinson/pkg_resources'
license=(MIT)
depends=(
  python
  python-packaging
  python-jaraco.text
  python-platformdirs
  python-typing_extensions
)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  python-pytest
  python-jaraco.path
  python-jaraco.envs
  python-filelock
  python-path
)
source=("$pkgname::git+$url#tag=v$pkgver")
sha512sums=('d776ba7276223598f21a5c9d29c81319f28b87f8b38f6d7a0945e7025956eaf6ec4fe34977e1672153ca6815bb53022192d8c640010d27e29922a4dd8ef4ac0c')
b2sums=('1cd3cedd0b1cb5503ccd395e8db7b43c781b4d0abc1a1cc4a590c6eec40d4dba86a5c0193d04ffa4a634179e9a6070ac1d8b1f2a28b24c52c1d29262ebb03c0d')

prepare() {
  cd "$pkgname"

  # global gitignore excluded tests, whoops.
  git cherry-pick --no-commit b79bafcc0ef9f4cf06a145592282588787be3692
}

build() {
  cd "$pkgname"

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

check() {
  cd "$pkgname"

  local pytest_args=(
    --verbose
    --deselect tests/test_integration_zope_interface.py::test_interop_pkg_resources_iter_entry_points
    --deselect tests/test_resources.py::TestEntryPoints::testBasics
    --deselect tests/test_resources.py::TestEntryPoints::testParse
  )

  PYTHONPATH="." pytest "${pytest_args[@]}"
}

package() {
  cd "$pkgname"

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

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