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

pkgname=python-flexmock
pkgver=0.12.0
pkgrel=1
pkgdesc="Mock/Stub/Spy library for Python"
arch=('any')
url="https://flexmock.readthedocs.io"
license=('BSD-2-Clause')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-poetry-core')
checkdepends=('python-pytest' 'python-teamcity-messages' 'python-testtools' 'python-twisted')
source=("https://github.com/flexmock/flexmock/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('a157c5ccb88a1e00bac9124145f882e59633f406971df0940579a12b9e161a787790a0ce27664997faa6ddc7c8926122359bd5b31fae0d31c729e5ed140e745e')

export LC_CTYPE=en_US.UTF-8

build() {
  cd flexmock-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd flexmock-$pkgver
  PYTHONPATH="$PWD/src" pytest -p flexmock._pytest_plugin
}

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

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/flexmock-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
