# Maintainer: Andrew Sun <adsun701@gmail.com>

_pyname=PrettyTable
_realname=prettytable
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=2.1.0
pkgrel=1
pkgdesc="A simple Python library for easily displaying tabular data (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://pypi.python.org/pypi/PrettyTable"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-wcwidth")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools-scm")
options=('staticlibs' 'strip' '!debug')
_dtoken=dc2e9370bf3be766302dbd6cd9729e258e875d31a7a21c9f760aaa5b5b5e
source=("${_realname}-${pkgver}.tar.gz::https://files.pythonhosted.org/packages/source/P/PrettyTable/${_realname}-${pkgver}.tar.gz"
        "0001-Fix-column-spacing-with-xterm-reset-escape-sequence.patch")
sha256sums=('5882ed9092b391bb8f6e91f59bcdbd748924ff556bb7c634089d5519be87baa0'
            'e9dd93c51ca3769c41cd2b7b27c58d8e6683fd4b6f4665291ad542d7917765d0')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/0001-Fix-column-spacing-with-xterm-reset-escape-sequence.patch"

  cd "${srcdir}"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  msg "Python build for ${CARCH}"  
  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
}
