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

_realname=astroid
pkgbase=mingw-w64-python3-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.1.0
pkgrel=1
pkgdesc="Useful miscellaneous modules used by Logilab projects (mingw-w64)"
arch=('any')
url="https://github.com/PyCQA/astroid"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-python3-six"
         "${MINGW_PACKAGE_PREFIX}-python3-lazy-object-proxy"
         "${MINGW_PACKAGE_PREFIX}-python3-wrapt")
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python3-dateutil"
              "${MINGW_PACKAGE_PREFIX}-python3-pytest"
              "${MINGW_PACKAGE_PREFIX}-python3-numpy"
              "${MINGW_PACKAGE_PREFIX}-python3-nose")
source=(https://github.com/PyCQA/astroid/archive/astroid-$pkgver.tar.gz)
sha512sums=('e49a191ceac7840caf4194bf710e223f70dcd82c40679d642ea16d0e21de75a33459066650a9ba82c4017de1442afef0775fe77954ebde59dae265c9c8e9fecc')

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

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

check() {
  msg "Python 3 test for ${CARCH}"
  cd "${srcdir}/python3-build-${CARCH}"
  ${MINGW_PREFIX}/bin/pytest || warning "Tests failed"
}

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

}
