# Contributor: Runar Tenfjord < runar dot tenfjord at gmail dot com >

_realname=statsmodels
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=0.11.1
pkgrel=1
pkgdesc="Statistical computations and models for use with SciPy (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://statsmodels.sourceforge.io/"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python-scipy"
         "${MINGW_PACKAGE_PREFIX}-python-pandas"
         "${MINGW_PACKAGE_PREFIX}-python-patsy")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-nose: needed for integrated test suite"
            "${MINGW_PACKAGE_PREFIX}-python-matplotlib: needed for plotting functions")
makedepends=("${MINGW_PACKAGE_PREFIX}-cython"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-gcc")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz"
        001-dont-include-extra-files.patch)
sha256sums=('5bde3fa0a35a91b45dba7cbc28270b5b649ff1d721c89290883f6e831672d5f0'
            '4d027a41038fc211ae37c64c6a019616feef8e36164c2f269410b4b38f682e91')

prepare() {
  cd "${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/001-dont-include-extra-files.patch

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

build() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${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 --skip-build \
    --prefix=${MINGW_PREFIX} --root=${pkgdir} --optimize=1

  install -Dm644 LICENSE.txt \
    "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
