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

_realname=astroid
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.4.2
pkgrel=1
pkgdesc="Useful miscellaneous modules used by Logilab projects (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/PyCQA/astroid"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-python-six"
         "${MINGW_PACKAGE_PREFIX}-python-lazy-object-proxy"
         "${MINGW_PACKAGE_PREFIX}-python-wrapt"
         "${MINGW_PACKAGE_PREFIX}-python-typed_ast")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-dateutil"
              "${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-numpy"
              "${MINGW_PACKAGE_PREFIX}-python-nose"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-runner")
source=(https://github.com/PyCQA/astroid/archive/astroid-${pkgver}.tar.gz)
sha512sums=('5306428e55bb8fec388353844afb842638114d6163096d4eb4335ac488a88b7a09a03d143e3ea991ea07371d9d87e911578981e4d74e45f6b3819e389f227ba0')

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

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

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

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
}
