archrelease: copy trunk to community-any
[ArchLinux/community.git] / python-python-pkcs11 / trunk / PKGBUILD
blobfcc6db9244fc88c3252cddb6a108910204ea0840
1 # Maintainer: Jonas Witschel <diabonas@archlinux.org>
2 pkgname=python-python-pkcs11
3 _name=${pkgname#python-}
4 pkgver=0.7.0
5 pkgrel=6
6 pkgdesc='PKCS#11/Cryptoki support for Python'
7 arch=('x86_64')
8 url='https://github.com/danni/python-pkcs11'
9 license=('MIT')
10 depends=('python' 'python-asn1crypto' 'python-cached-property')
11 makedepends=('cython' 'python-build' 'python-installer' 'python-setuptools'
12              'python-setuptools-scm' 'python-wheel')
13 checkdepends=('python-cryptography' 'python-oscrypto' 'python-pytest' 'softhsm')
14 source=("https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz"
15         'python-pkcs11_mark-tests-as-xfail.patch')
16 sha256sums=('9737e0c24cabb8bc9d48bf8c57c3df2a70f8cdd96b70c50290803286f9e46bf7'
17             '28a5ce996fe6cb455b55c98e8a46fcd0539dc0b3a70677a390f4dddbe1b55d65')
19 prepare() {
20         cd "$_name-$pkgver"
22         sed -n '/^Copyright/,$p' README.rst > LICENSE
24         # test_sign_eddsa and test_self_sign_certificate always fail in our build environment
25         # (https://github.com/danni/python-pkcs11/issues/63#issuecomment-526812900)
26         patch --forward --strip=1 --input="$srcdir/python-pkcs11_mark-tests-as-xfail.patch"
29 build() {
30         cd "$_name-$pkgver"
31         python -m build --wheel --no-isolation
34 check() {
35         cd "$_name-$pkgver"
36         softhsm2-util --init-token --free --label TEST --pin 1234 --so-pin 5678
37         export PKCS11_MODULE=/usr/lib/libsofthsm2.so
38         export PKCS11_TOKEN_LABEL=TEST
39         export PKCS11_TOKEN_PIN=1234
40         export PKCS11_TOKEN_SO_PIN=5678
41         local _python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
42         PYTHONPATH="$PWD/build/lib.linux-$CARCH-cpython-$_python_version" pytest --import-mode=append
45 package() {
46         cd "$_name-$pkgver"
47         python -m installer --destdir="$pkgdir" dist/*.whl
48         install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"