# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Lex Black <autumn-wind at web dot de>
# Contributor: Igor Nemilentsev <trezorg@gmail.com>
# Contributor: Alexander Diana <alexander@rouk.org>

pkgname=python-bcrypt
pkgver=4.2.0
pkgrel=2
pkgdesc="Modern password hashing for your software and your servers"
arch=('x86_64' 'aarch64')
url="https://github.com/pyca/bcrypt"
license=('Apache')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-setuptools-rust' 'python-wheel')
checkdepends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/pyca/bcrypt/archive/$pkgver.tar.gz")
sha512sums=('5c1b3f19530338b421a76122c9f29f1397d1315234db025530b71254f7dd021c6406ee4a58668c28959afc86a59535c4230f5bce8bfddc8fea3064996ef5b7d7')

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

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd bcrypt-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH" pytest
}

package() {
  cd bcrypt-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
}
