# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Massimiliano Torromeo < massimiliano DOT torromeo AT gmail DOT com >

pkgname=python-asn1crypto
pkgver=1.5.1
pkgrel=4
arch=(any)
license=('MIT')
pkgdesc="Python ASN.1 library with a focus on performance and a pythonic API"
url="https://github.com/wbond/asn1crypto"
depends=('python')
makedepends=('python-setuptools')
source=("$pkgname-$pkgver.tar.gz::https://github.com/wbond/asn1crypto/archive/$pkgver.tar.gz"
	"0001-Import-backflips-that-work-with-Python-3.12.patch")
sha512sums=('1bcb93d82a2602e3b5c66a180f5d16cd3a9731d86d89fbd44c1e23d735e708e9bf9bb6cbabc2a5d60619f51a7c38dfb1f7ed63820f422ccf42800a39f4637626'
            '1921c21e33c6469ab8a02be945902b43f52ebbc523b955e010a1f823cccfe28297812f4a1cd54e22ffa2fad8e6fae59dda4263fe68921943e55ed3dfb23d7034')

prepare() {
  cd "$srcdir"/asn1crypto-$pkgver
  # imp modules is removed in Python 3.12
  patch -Np1 -i ${srcdir}/0001-Import-backflips-that-work-with-Python-3.12.patch
}

build() {
  cd "$srcdir"/asn1crypto-$pkgver
  python setup.py build
}

check() {
  cd "$srcdir"/asn1crypto-$pkgver
  python run.py tests
}

package() {
  cd asn1crypto-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1
  install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/python-asn1crypto/LICENSE
}
