# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=pluggy
pkgbase=python-pluggy
pkgname=(python-${_realname})
pkgver=1.6.0
pkgrel=1
pkgdesc="Plugin and hook calling mechanisms for python"
arch=('any')
url="https://github.com/pytest-dev/pluggy"
msys2_references=(
  "purl: pkg:pypi/pluggy"
)
license=('spdx:MIT')
depends=('python')
makedepends=(
  'python-setuptools'
  'python-setuptools-scm'
  'python-build'
  'python-installer'
)
provides=("python3-${_realname}")
replaces=("python3-${_realname}")
conflicts=("python3-${_realname}")
source=("${pkgbase}-${pkgver}.tar.gz::https://github.com/pytest-dev/pluggy/archive/${pkgver}.tar.gz")
sha512sums=('c32690cd2737605aff80d20db126d47cde6d7a48f6717c198b37aa8721f895351a684a15484499d76f93331829776e3d9157399a297f75495b681929742f572f')

prepare() {
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"

  python -m pytest
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"

  python -m installer --destdir="${pkgdir}" dist/*.whl
  install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
