# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>

pkgname=python-invoke
pkgver=2.2.1
pkgrel=1
pkgdesc="Pythonic task execution"
arch=('any')
url="https://github.com/pyinvoke/invoke"
license=('BSD-2-Clause')
depends=(
  'python'
  'python-fluidity'
  'python-lexicon'
  'python-yaml'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=(
  'python-icecream'
  'python-pytest'
  'python-pytest-relaxed'
)
source=("$url/archive/$pkgver/${pkgname#python-}-$pkgver.tar.gz")
sha512sums=('7ef1bd311c89446667fb56f6de6308fb5ffec545178bb069a1a367006b7a15ab131388c52f20b90b3b128f2a31c1c819647aa39560df75e845f33b3be51f4aee')

prepare() {
  cd ${pkgname#python-}-$pkgver
  rm -r invoke/vendor
}

build() {
  cd ${pkgname#python-}-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd ${pkgname#python-}-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest -s \
    --deselect tests/runners.py::Local_::env::uses_execve_for_pty_True \
    --deselect tests/runners.py::Local_::pty \
    --deselect tests/runners.py::Local_::shell::defaults_to_bash_or_cmdexe_when_pty_True \
    --deselect tests/runners.py::Local_::shell::may_be_overridden_when_pty_True
}

package() {
  cd ${pkgname#python-}-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
