_realname='pyproject-metadata'
_pyname="${_realname/-/_}"
pkgname="python-${_realname}"
pkgver=0.12.1
pkgrel=1
pkgdesc='PEP 621 metadata parsing'
arch=('any')
url='https://pep621.readthedocs.io/'
msys2_repository_url='https://github.com/pypa/pyproject-metadata'
msys2_changelog_url='https://pep621.readthedocs.io/en/latest/changelog.html'
msys2_references=(
  'anitya: 255630'
  'archlinux: python-pyproject-metadata'
  "gentoo: dev-python/pyproject-metadata"
  'purl: pkg:pypi/pyproject-metadata'
)
license=('spdx:MIT')
depends=(
  'python'
  'python-packaging'
)
makedepends=(
  'python-build'
  'python-flit-core'
  'python-installer'
)
checkdepends=(
  'python-pytest'
  # 'python-pytest-cov' # missing
)
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('8809a4df6fe08279b39a8890669506ed3158e0617855ac9aff098fcbe772ae4c')

build() {
  cp -r "${_pyname}-${pkgver}" 'python-build' && cd 'python-build'

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

check() {
  cd 'python-build'

  # 0.12.1: 0 failed, 318 passed, 88 skipped
  PYTHONPATH="${PWD}" python -m pytest || warning "Tests failed"
}

package() {
  cd 'python-build'

  python -m installer --prefix=/usr --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}
