# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

pkgname=python-trio-asyncio
pkgver=0.15.0
pkgrel=2
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
)
_tag=d4a510072d88f7217b6b4a081c5f6e5247a66233
source=(git+https://github.com/python-trio/trio-asyncio.git#tag=${_tag})
b2sums=('f39e13d8bf8c5fdb5f994a67cbb4fbf844d12cfe1cf4cc11b50aac5fadf38b4c0cd4ca145a206a44e88fa98b20dda69c31ae46dcb256419f422d137a8e7330b4')

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]
    --deselect /Python-3.13/test_asyncio/test_ssl.py::TestSSL::test_create_connection_ssl_1
  )
  cd trio-asyncio
  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:
