# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=statistics
pkgbase=mingw-w64-python2-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-python2-${_realname}"
pkgver=1.0.3.5
pkgrel=1
pkgdesc="A Python 2.* port of 3.4 Statistics Module (mingw-w64)"
arch=('any')
url='https://pypi.python.org/pypi/statistics'
license=('PSF')
depends=("${MINGW_PACKAGE_PREFIX}-python2-docutils")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("https://pypi.python.org/packages/source/s/${_realname#*-}/${_realname#*-}-${pkgver}.tar.gz")
sha512sums=('1d7fd2304a885dbd9ebc564323349f9c5ad1ea1ecea8182b52a1f42308963bd49f07c9dc9f0b87a35d2f6ed3c37429dbc38183c0b1bd65a527558e4504a9a3a0')

prepare() {
  cd "${srcdir}"
  rm -rf python2-build-${CARCH}| true
  cp -r "${_realname}-${pkgver}" "python2-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

build() {
    msg "Python 2 build for ${CARCH}"
    cd "${srcdir}/python2-build-${CARCH}"
    ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
     --root="${pkgdir}" --optimize='1' --skip-build

  install -dm 755 "${pkgdir}"${MINGW_PREFIX}/share/licenses/python2-${_realname}
}
