# Maintainer: ciciwu <yw@m-labs.hk>

_realname=pyqtgraph
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.13.7
pkgrel=3
pkgdesc='Scientific Graphics and GUI Library for Python.'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.pyqtgraph.org/"
msys2_repository_url='https://github.com/pyqtgraph/pyqtgraph'
msys2_references=(
  'archlinux: python-pyqtgraph'
  'purl: pkg:pypi/pyqtgraph'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-numpy")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-pyqt5"
            "${MINGW_PACKAGE_PREFIX}-python-pyside2-qt5"
            "${MINGW_PACKAGE_PREFIX}-python-pyqt6"
            "${MINGW_PACKAGE_PREFIX}-python-pyside6"
            "${MINGW_PACKAGE_PREFIX}-python-scipy: Image processing & Data array filtering"
            "${MINGW_PACKAGE_PREFIX}-python-pyopengl: 3D graphics & Faster image processing"
            "${MINGW_PACKAGE_PREFIX}-python-h5py: Export in hdf5 format"
            "${MINGW_PACKAGE_PREFIX}-python-matplotlib: Export of PlotItem in matplotlib figure & Add matplotlib collection of colormaps"
            "${MINGW_PACKAGE_PREFIX}-python-numba: Faster image processing")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('64f84f1935c6996d0e09b1ee66fe478a7771e3ca6f3aaa05f00f6e068321d9e3')

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

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.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
