# Maintainer: Konstantin Gizdov <arch at kge dot pw>
# Contributor: Baptiste Jonglez <archlinux at bitsofnetworks dot org>
# Contributor: Immae

pkgname=python-pybtex
pkgver=0.25.1
pkgrel=1
pkgdesc="A BibTeX-compatible bibliography processor written in Python"
arch=("any")
url="https://pybtex.org"
license=("GPL")
# Overridden in package_* functions
makedepends=('python-setuptools' 'python-build' 'python-installer' 'python-wheel')
depends=('python' 'python-setuptools' 'python-yaml' 'python-latexcodec')
checkdepends=('python-pytest')
source=("https://pypi.io/packages/source/p/pybtex/pybtex-$pkgver.tar.gz")
sha256sums=('9eaf90267c7e83e225af89fea65c370afbf65f458220d3946a9e3049e1eca491')

get_pyver () {
    python -c 'import sys; print(str(sys.version_info[0]) + "." + str(sys.version_info[1]))'
}

build() {
  cd "${srcdir}/pybtex-${pkgver}"
  python -m build --wheel --no-isolation
}

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

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

  # Files under site-packages/tests/ conflict with other python packages.
  rm -rf "${pkgdir}/usr/lib/python$(get_pyver)"/site-packages/tests
}
