# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-pyu2f
pkgver=0.1.5
pkgrel=11
pkgdesc="U2F host library for interacting with a U2F device over USB"
url="https://github.com/google/pyu2f"
license=('Apache-2.0')
arch=('any')
depends=('python-six')
makedepends=('git' 'python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-pyfakefs' 'python-pytest')
source=("git+https://github.com/google/pyu2f.git#tag=$pkgver" "pyfakefs-compat.patch" "use-unittest-mock.patch"
	"unittest-3.12-compatibility.patch")
sha512sums=('0eedb79719f3144fdae6689697b57ccc287fbbd206fbc4d1f10906851ce3c196ad19d6cb65425331c26d90826922a419ceb73bde0a862508c519a6ddd1fbde91'
            'ef12d29114292918d5820ff129cfcfa820637464e1945252c5fca80be40cfb8d5df5d57efc8dac748d1b952acca177c953a69a3a16d096c92bd8a61687b80fe0'
            '52d6544ba242bf762e75520b0f11656e7fb0abdbf229a7735e3621244c95a9f2926503dfee69c368dcf9464879c70079a3032cfc4fc086f6972b3b74be9007f7'
            '8a9b6cae308e5d29e902c715066c6508ab2d8b584d07008d3e36c563bfebec3fd3913d507af1b573d1d8d3d16ab7fc67099e3fd77b6d1194d78c244510ca9831')

prepare() {
  cd pyu2f
  patch -Np1 -i "$srcdir"/pyfakefs-compat.patch
  # Use Python's builtin unittest.mock
  patch -Np1 -i "$srcdir"/use-unittest-mock.patch
  # assertEquals is gone in 3.12
  patch -Np1 -i "$srcdir"/unittest-3.12-compatibility.patch
}

build() {
  cd pyu2f
  python -m build --wheel --no-isolation
}

check() {
  cd pyu2f
  pytest
}

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