# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>

_pkgname=cleo
pkgname=python-cleo
pkgver=2.1.0
pkgrel=1
epoch=1
pkgdesc='create beautiful and testable command-line interfaces'
arch=(any)
url="https://github.com/python-poetry/$_pkgname"
license=(MIT)
depends=(python-crashtest
         python-rapidfuzz
         python-typing_extensions)
makedepends=(python-{build,installer,wheel}
             python-poetry-core)
checkdepends=(python-pytest
              python-pytest-mock)
_archive="$_pkgname-$pkgver"
source=("$url/archive/$pkgver/$_archive.tar.gz")
sha256sums=('f5905052d783d540271de62b546c8ad89792e8c2787a59c41b0d8c8c31934093')
b2sums=('7c9d0cc869d1e185c2c5a092a8aa1d1b3cce5fc25246939c0ff94920ac7070000b110be9f6cd9d1f827ed951ff22b9ad62e3c17a941022967b7599e456cda837')

prepare() {
    cd "$_archive"
    # we do not use overly strict version constraints
    sed -e 's/\^/>=/g' \
        -e 's/~=/>=/g' \
        -i pyproject.toml
}

build(){
    cd "$_archive"
    python -m build -wn
}

check() {
    cd "$_archive"
    export PYTHONPATH="$PWD/src"
    pytest -vv
}

package() {
    cd "$_archive"
    python -m installer -d "$pkgdir" dist/*.whl
    install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}
