# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=python-trio-asyncio
_name=${pkgname#python-}
pkgver=0.14.0
pkgrel=3
pkgdesc='A re-implementation of the asyncio mainloop on top of Trio'
arch=(any)
url=https://github.com/python-trio/trio-asyncio
license=(
  'Apache-2.0 OR MIT'
)
depends=(
  python
  python-greenlet
  python-outcome
  python-sniffio
  python-trio
)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  python-pytest
  python-pytest-timeout
  python-pytest-trio
  python-tests
)
source=(git+$url.git#tag=v$pkgver)
sha256sums=('7c3dac6670f2f1ded5b710e704ce67d30bda95ec9e8ca633a27c364dc8efb898')

prepare() {
  sed '/pytest-runner/d' -i trio-asyncio/setup.py
}

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

check() {
  local pytest_options=(
    -vv
    --deselect tests/interop/test_calls.py::TestCalls::test_trio_asyncio_cancel_direct
    --deselect tests/test_misc.py::test_keyboard_interrupt_teardown
    --deselect tests/test_misc.py::test_cancel_loop[True]
    --deselect tests/test_misc.py::test_run_trio_task_errors
    --deselect tests/test_trio_asyncio.py::test_cancel_loop_with_tasks[True-False]
    --deselect tests/test_trio_asyncio.py::test_cancel_loop_with_tasks[True-True]
  )
  cd $_name
  pytest "${pytest_options[@]}"
}

package() {
  python -m installer --destdir="${pkgdir}" trio-asyncio/dist/*.whl
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  rm -rf "${pkgdir}"${site_packages}/tests
  install -Dm 644 trio-asyncio/LICENSE -t "${pkgdir}"/usr/share/licenses/python-trio-asyncio/
  install -Dm 644 trio-asyncio/LICENSE.MIT -t "${pkgdir}"/usr/share/licenses/python-trio-asyncio/
}

# vim: ts=2 sw=2 et:
