# Maintainer: Kyle Kauffman <kyle.j.kauffman@gmail.com>

_realname=ipython
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=8.32.0
pkgrel=1
pkgdesc="An enhanced Interactive Python shell (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: ipython'
  'pypi: ipython'
  "cpe: cpe:/a:ipython:ipython"
)
msys2_repository_url='https://github.com/ipython/ipython/'
msys2_documentation_url='https://ipython.readthedocs.org/'
url="https://ipython.org/"
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-colorama"
         "${MINGW_PACKAGE_PREFIX}-python-decorator"
         "${MINGW_PACKAGE_PREFIX}-python-jedi"
         "${MINGW_PACKAGE_PREFIX}-python-matplotlib-inline"
         "${MINGW_PACKAGE_PREFIX}-python-prompt_toolkit"
         "${MINGW_PACKAGE_PREFIX}-python-pygments"
         "${MINGW_PACKAGE_PREFIX}-python-stack-data"
         "${MINGW_PACKAGE_PREFIX}-python-traitlets"
         "winpty")
if [[ ${CARCH} != i686 ]]; then
optdepends=("${MINGW_PACKAGE_PREFIX}-python-qtconsole: for ipython qtconsole"
            "${MINGW_PACKAGE_PREFIX}-python-ipython-ipyparallel: for IPython.parallel")
fi
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-asyncio"
              "${MINGW_PACKAGE_PREFIX}-python-testpath"
              "${MINGW_PACKAGE_PREFIX}-python-pickleshare"
              "${MINGW_PACKAGE_PREFIX}-python-matplotlib"
              "${MINGW_PACKAGE_PREFIX}-python-jupyter-nbformat"
              "${MINGW_PACKAGE_PREFIX}-python-numpy")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('be2c91895b0b9ea7ba49d33b23e2040c352b33eb6a519cca7ce6e0c743444251')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

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

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-ipython/LICENSE"
}
