# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=imbalanced-learn
pkgbase=mingw-w64-python3-${_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.6.1
pkgrel=1
pkgdesc="A Python Package to Tackle the Curse of Imbalanced Datasets in Machine Learning (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='https://github.com/scikit-learn-contrib/imbalanced-learn'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-joblib"
         "${MINGW_PACKAGE_PREFIX}-python-numpy"
         "${MINGW_PACKAGE_PREFIX}-python-scikit-learn"
         "${MINGW_PACKAGE_PREFIX}-python-scipy")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-cython")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-keras"
            "${MINGW_PACKAGE_PREFIX}-python-tensoflow")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/scikit-learn-contrib/${_realname}/archive/${pkgver}.tar.gz")
sha256sums=('fb8e37ba2f7ec3b338ed711b362690f31cfe2cc7202c9868602698f957304680')

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

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=0 --skip-build

  install -D LICENSE "$pkgdir"/${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
