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

_realname=ipython
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=8.22.2
pkgrel=2
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"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
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=('2dcaad9049f9056f1fef63514f176c7d41f930daa78d05b82a176202818f2c14')

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

build() {
  cd "${srcdir}/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"
}
