# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: googol <googol@posteo.de>
# Contributor: Oliver Mangold <o.mangold at gmail dot com>

pkgname=python-alembic
pkgver=1.13.1
pkgrel=3
pkgdesc='Lightweight database migration tool for usage with SQLAlchemy'
url='https://github.com/sqlalchemy/alembic'
arch=(any)
license=('MIT')
depends=('python' 'python-mako' 'python-sqlalchemy' 'python-typing_extensions')
makedepends=('python-setuptools' 'python-build' 'python-installer' 'python-wheel')
checkdepends=('python-pytest')
source=(
  $pkgname-$pkgver.tar.gz::https://github.com/sqlalchemy/alembic/archive/refs/tags/rel_${pkgver//./_}.tar.gz
  $pkgname-1.13.1-pytest-8.1.patch::https://github.com/sqlalchemy/alembic/commit/6bdb9043868d4bd04ebe3fe8a4991735d5f87ed3.patch
)
sha512sums=('85a94874a4c26e8c38f5fa76c0d4ab428a54c663c5a53547d5652e0f081245080168e4696f3afff5b574a5d2a673f02828d1fd77649ed59a150187030776238b'
            'e3c5aff773c5a82babaffbc9a462a22efea7ae3fa3d6ece2757042dedbad62a31441355c0701601c1b138abc663fe8ba0bcaa6cff2501e407ea851b82f6dce06')
b2sums=('12445947193d7ad3b16016660d0f21eaeefbafdc72afb5cbabb206dcda001295633f3bcc5dd599d2bc0cbfb30fafaf74344aed5d5afa6679b3bb7a08f418cc3b'
        '40d884aa7f61baf1ed3c4dbec98cc1c5c46837f6935d0ec0f8897615dc69c0f819744d3dcc0b40a000294b1deb5f425f36697ff24cfc1110a009d060b18b8c15')

prepare() {
  cd alembic-rel_${pkgver//./_}
  # fix for pytest >= 8.1: https://github.com/sqlalchemy/alembic/issues/1435
  patch -Np1 -i ../$pkgname-1.13.1-pytest-8.1.patch
  # do not treat warnings as errors
  sed 's|-p no:warnings||g' -i setup.cfg
}

build() {
  cd alembic-rel_${pkgver//./_}
  python -m build --wheel --no-isolation
}

check() {
  cd alembic-rel_${pkgver//./_}
  pytest -vv
}

package() {
  cd alembic-rel_${pkgver//./_}
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.rst CHANGES -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
