# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

pkgname=python-libevdev
pkgver=0.13.1
pkgrel=1
arch=('any')
url='https://gitlab.freedesktop.org/libevdev/python-libevdev'
license=('MIT')
pkgdesc='Python wrapper for libevdev'
depends=('python' 'libevdev')
makedepends=('python-build' 'python-installer' 'python-hatchling' 'python-sphinx' 'python-sphinx_rtd_theme')
checkdepends=('python-pytest')
source=("$url/-/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('702af275047848a76a6a4fc4c20f8ba09a12bd1b1f4cc96ab80535667213b9e690227b450b375a43573b4b350956b8df3ba402aa8176ac07836fc140e6063d82')

build() {
  cd $pkgname-$pkgver

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

  make doc
}

check() {
  cd $pkgname-$pkgver

  python -m pytest test/*.py
}

package() {
  cd $pkgname-$pkgver

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

  # Install documentation
  install -dm 755 "$pkgdir"/usr/share/doc/$pkgname
  cp -r -a --no-preserve=ownership doc/html "$pkgdir"/usr/share/doc/$pkgname
  install -D -m644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
  rm -rf "$pkgdir"/usr/share/doc/$pkgname/html/.doctrees
}
