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

pkgname=python-flexmock
pkgver=0.12.2
pkgrel=1
pkgdesc="Mock/Stub/Spy library for Python"
arch=('any')
url="https://flexmock.readthedocs.io"
license=('BSD-2-Clause')
depends=('python')
makedepends=('git' 'python-build' 'python-installer' 'python-poetry-core')
checkdepends=('python-pytest' 'python-teamcity-messages' 'python-testtools' 'python-twisted')
source=("git+https://github.com/flexmock/flexmock.git#tag=v$pkgver")
sha512sums=('86b1890a65ebf04c47155cd9bf2fff3449c92e7ac8a3e22605f05c9dd990b0089e37bb1ea9e980134035f0ff09cc878c239693e359008b62ff4e80d91d3e212d')

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

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

package() {
  cd flexmock
  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
}
