# Maintainer: fsagbuya <fa@m-labs.ph>

_realname=pylablib
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.4.4
pkgrel=1
pkgdesc="Python package for device control and experiment automation (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/AlexShkarin/pyLabLib"
msys2_references=(
    'purl: pkg:pypi/pylablib'
)
msys2_changelog_url='https://pylablib.readthedocs.io/en/latest/changelog.html'
license=('spdx:GPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-numpy"
         "${MINGW_PACKAGE_PREFIX}-python-scipy"
         "${MINGW_PACKAGE_PREFIX}-python-pandas"
         "${MINGW_PACKAGE_PREFIX}-python-rpyc"
         "${MINGW_PACKAGE_PREFIX}-python-numba"
         "${MINGW_PACKAGE_PREFIX}-python-pyvisa"
         "${MINGW_PACKAGE_PREFIX}-python-pyserial"
         "${MINGW_PACKAGE_PREFIX}-python-pyusb"
         "${MINGW_PACKAGE_PREFIX}-python-pyft232"
         "${MINGW_PACKAGE_PREFIX}-python-pyqt5"
         "${MINGW_PACKAGE_PREFIX}-python-pyqtgraph")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-cc")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('a62facb3b232adbc8f00dbe5ec604768f2c8d5915f96ad98a5acc12ac70b9ea8')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

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