# Maintainer: David Runge <dvzrv@archlinux.org>

_name=loguru
pkgname=python-loguru
pkgver=0.7.3
pkgrel=2
pkgdesc="Python logging made (stupidly) simple"
arch=(any)
url="https://github.com/Delgan/loguru"
license=(MIT)
depends=(python)
makedepends=(
  python-build
  python-flit-core
  python-installer
)
checkdepends=(
  python-colorama
  python-freezegun
  python-pytest
)
source=(
  $_name-$pkgver.tar.gz::$url/archive/refs/tags/$pkgver.tar.gz
  $_name-0.7.3-update_mypy_deps.patch # ::https://github.com/Delgan/loguru/commit/8bba363a12483b419a27f17212b9368bc3105677.patch
  $_name-0.7.3-disable_mypy_tests.patch # ::https://github.com/Delgan/loguru/commit/e17479bd0701e8fc0b26981339540599dc224d11.patch
  $_name-0.7.3-fix_exception_modern.patch # ::https://github.com/Delgan/loguru/commit/84023e2bd8339de95250470f422f096edcb8f7b7.patch
)
sha256sums=('1cad8860aa0ecf9567125381e4430046526246e075224350a6a624addac05f5e'
            '639d17b03ed8e8d3874a4ca964fbe00df75b600e293423aeb1978592f70dd31b'
            '2599b71d1f6530afa6440b5fd7ab1a8baa41a0c1e32f27a800a7c4b96701bbd6'
            '8d5b0207e0bb4bd250bd4f32fe77dcb218023591958a79df010297c02d0b4bd2')
b2sums=('7d7cf167e1350814eea6a358cc00bac217ea6b153ae29ffd70c026f3be63cc126fbc184668ea643ea03416fc8f805bd51502fd8cc9e8d9bcc19099814b8c3fe6'
        '6881a3b6418ef3301ea35aefc1efc38446e69676bd77612f4a879b1c23d6350c5ed453b6e5ec96d5561d312b5d9191b6ea449373e74fc9143cdeca11ea959598'
        'f8ce1f86c312e3e9b51d22f0310875aa9ffc5c200d82bd0c2f8866ce04e612ca4b72da3697e9f642c15e2b7e423e2392aaeb049362de2fc33a76cb3842f201f9'
        'b7ecbeb1dce97bca549a2830e055ae30727a68cacf054f092dca57a0e4ad59c50e12e5926d735862f5da12a6c08a0189382049b0f36dc7d5cd4aa5f215262e08')

prepare() {
  patch -Np1 -d $_name-$pkgver -i ../$_name-0.7.3-update_mypy_deps.patch
  patch -Np1 -d $_name-$pkgver -i ../$_name-0.7.3-disable_mypy_tests.patch
  patch -Np1 -d $_name-$pkgver -i ../$_name-0.7.3-fix_exception_modern.patch
}

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

check() {
  local pytest_options=(
    -vv
    --ignore tests/test_type_hinting.py  # we don't care about type hints
  )

  cd $_name-$pkgver
  pytest "${pytest_options[@]}"
}

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