# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Chih-Hsuan Yen <yan12125@archlinux.org>
# Contributor: Andrzej Giniewicz <gginiu@gmail.com>
# Contributor: Nishit Joseph (reachjlight at gmail dot com)
# Contributor: Martin Corley <Martin.Corley@ed.ac.uk>

pkgname=python-openpyxl
_pkgname="${pkgname#python-}"
pkgver=3.1.5
pkgrel=2
pkgdesc='A Python library to read/write Excel 2010 xlsx/xlsm/xltx/xltm files'
arch=('any')
url='https://openpyxl.readthedocs.org'
license=('MIT')
depends=(
  'python'
  'python-et-xmlfile'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=(
  'python-defusedxml'
  'python-pytest'
  'python-lxml'
  'python-pandas'
  'python-pillow'
)
optdepends=(
  'python-pillow: needed to include images'
  'python-lxml: alternative XML backend'
  'python-defusedxml: guard against various XML vulnerabilities'
  'python-pandas: for iteration over Pandas DataFrames'
)
source=("https://foss.heptapod.net/openpyxl/openpyxl/-/archive/${pkgver}/openpyxl-${pkgver}.tar.bz2")
sha512sums=('556d3f1660ae5d045b0801b99740b2cd1eea1fc69c07c87c4bdd7e78999b5094e84db6fcb107b2a80f4648004810d18eea22779e2d3c231a996bbe2a12d33288')
b2sums=('7a70de814c39945ce4ed8c1e8105da9db4347b4a5f90e6620f6a22f85ba55e2330a305a9d6f78ab27f2055b589b6f3beba6943d8c15cbb9a24e94d663bffcf1d')

build() {
  cd "$_pkgname-$pkgver"

  python -m build --wheel --no-isolation
}

check() {
  cd "$_pkgname-$pkgver"

  pytest -v
}

package() {
  cd "$_pkgname-$pkgver"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENCE.rst
}
