# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Jelle van der Waa <jelle@archlinux.org>
# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=python-validate-pyproject
pkgver=0.24.1
pkgrel=3
pkgdesc="Validation library and CLI tool for checking on 'pyproject.toml' files using JSON Schema"
arch=('any')
url="https://github.com/abravalheri/validate-pyproject"
license=('MPL-2.0')
depends=(
  'python'
  'python-fastjsonschema'
  'python-packaging'
  'python-trove-classifiers'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools-scm'
  'python-wheel'
)
checkdepends=('python-pytest')
source=(
  "git+$url.git#tag=v$pkgver"
  "$pkgname-fix-tests.patch"
)
b2sums=('a8fd8e18c89da60e0f43cd88abddaf108dcb95c307dc4061a9a4a2bedc4101e79c9d9b65d6f1f816721fa8b27126ee3a326a4b403385d4b11ca86990ce1d1a50'
        'fe7f25a0979b297b3a46a62f3507760e7afd83760928bdf8d68379a2a270f1e07bc1cd4365a6a93d51d28d0becf07376fe6a3bea6da137870bf4509b6a1d43c7')

prepare() {
  cd ${pkgname#python-}
  patch -Np1 < ../$pkgname-fix-tests.patch
}

build() {
  cd ${pkgname#python-}
  python -m build --wheel --no-isolation
}

check() {
  cd ${pkgname#python-}
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest --override-ini="addopts=" \
    -k "not test_examples_api \
        and not test_examples_cli \
        and not test_invalid_examples_api \
        and not test_invalid_examples_cli \
        and not test_invalid_pep639_license_expression"
}

package() {
  cd ${pkgname#python-}
  python -m installer --destdir="$pkgdir" dist/*.whl
}
