# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Aaron Schaefer <aaron@elasticdog.com>

pkgname=python-pexpect
pkgver=4.9.0
_tag=${pkgver%.0}
pkgrel=4
pkgdesc='For controlling and automating applications'
arch=(any)
url='https://github.com/pexpect/pexpect'
license=(MIT)
depends=(
  python
  python-ptyprocess
)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(
  man-db
  python-pytest
  zsh
)
source=(
  "git+$url#tag=$_tag"
  "$pkgname-python-3.13-compatibility.patch::https://src.fedoraproject.org/rpms/python-pexpect/raw/rawhide/f/794.patch"
  "$pkgname-fix-test.patch"
)
sha512sums=('cb0243b856fe56d7d86f055a002579bfa69a6842fddbd58680377ac4ffa390fbbc1867f42441dd80db9bae2fd8435ebf625ad8903afdf16e11436c9350cb6155'
            'ac8f16a04943f279bd76accac79d74c95d620bc777a3f93807f1d0394dd02b238036868749086364257d3473adacd978e2498686ef22b2bbb20b0cff8ae5da57'
            'b634e07ea0972f0fe9909db6dc366b29a05bd8beff148e6408ee63b894dd3d487680ad4eec291a8e85e911301041ab1323807b61964a36c45e2aac714f582349')

prepare() {
  cd ${pkgname#python-}
  patch -Np1 -i ../$pkgname-python-3.13-compatibility.patch
  patch -Np1 -i ../$pkgname-fix-test.patch
}

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

check() {
  cd ${pkgname#python-}
  pytest
}

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