# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=openpyxl
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=3.0.7
pkgrel=1
pkgdesc="A python library to read/write Excel 2007 xlsx/xlsm file (mingw-w64)"
url="https://openpyxl.readthedocs.io/"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-jdcal"
         "${MINGW_PACKAGE_PREFIX}-python-et-xmlfile"
         "${MINGW_PACKAGE_PREFIX}-python-defusedxml"
         "${MINGW_PACKAGE_PREFIX}-python-pandas"
         "${MINGW_PACKAGE_PREFIX}-python-pillow")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-pip"
             "${MINGW_PACKAGE_PREFIX}-python-pytest")
source=("https://foss.heptapod.net/openpyxl/openpyxl/-/archive/${pkgver}/openpyxl-${pkgver}.tar.bz2")
sha256sums=('767e4a1f0e50c40c1066e67f3541fbb2250c6fe67dc2c17122e181305c89815b')

prepare() {
  rm -rf python-build-${CARCH}
  cp -r "openpyxl-${pkgver}" "python-build-${CARCH}"
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENCE.rst ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
