# Maintainer: Eli Schwartz <eschwartz@archlinux.org>

_pkgname=py7zr
pkgname=python-py7zr
pkgver=0.11.3
pkgrel=1
pkgdesc="Pure python 7-zip library"
arch=('any')
url="https://github.com/miurahr/${_pkgname}"
license=('LGPL')
depends=('python-pycryptodome' 'python-texttable')
optdepends=('python-zstandard: zstd compression')
makedepends=('python-setuptools-scm')
checkdepends=('python-pytest-timeout' 'python-zstandard' 'pyannotate' 'p7zip')
source=("https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/${_pkgname}/${_pkgname}-${pkgver}.tar.gz"
        "0001-setup.cfg-remove-build-time-dependency-on-things-unr.patch")
sha256sums=('f9e872f02daf9be64ef35a0d69f5467a3ccbd028df0863ee39a2fbab5f80cc52'
            'eb6e1b95bb2fe56889337bc3fb2ee788bfe7eb7849667bd2c193c7a9a8158908')
b2sums=('7306fffb1f1422e9a1a6d475fa37217dda8a0e8af2e14ebfeddbfae5a98d117b2e61e6fa4d5e254623c839f48911a9b14b1bd32b294e9ac1a5b7ab18305950fb'
        'c8043f2631d783c1c4e8797fe12f517b06c1468860a32d2964b7f1e12d76728f3317f3ea76f380fe11a3c2dade52e95e492be107b537430a9ffb24b439f70ccd')

prepare() {
    cd "${srcdir}"/${_pkgname}-${pkgver}

    # thou shalt not force coverage reports on innocent unittest users
    sed -i '/^addopts/d' tox.ini

    # don't download unneeded setup_requires from PyPI
    # https://github.com/miurahr/py7zr/pull/286
    patch -p1 -i ../0001-setup.cfg-remove-build-time-dependency-on-things-unr.patch
}

build(){
    cd "${srcdir}"/${_pkgname}-${pkgver}

    python setup.py build
}

check() {
    cd "${srcdir}"/${_pkgname}-${pkgver}

    python -m pytest -rsx \
        --ignore tests/test_benchmark.py
}

package() {
    cd "${srcdir}"/${_pkgname}-${pkgver}

    python setup.py install --root="${pkgdir}" --optimize=1 --skip-build
}
