# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=zxing-cpp
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.3.0
pkgrel=1
pkgdesc="Python bindings for the zxing-cpp barcode library (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/zxing-cpp/zxing-cpp'
msys2_references=(
  'purl: pkg:pypi/zxing-cpp'
)
license=('spdx:Apache-2.0')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-cmake"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-pybind11"
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
)
options=('!strip')
source=(
  "https://pypi.org/packages/source/${_realname::1}/${_realname/-/_}/${_realname/-/_}-${pkgver}.tar.gz"
  0001-setup-check-msc-python.patch
)
sha256sums=('3babedb67a4c15c9de2c2b4c42d70af83a6c85780c1b2d9803ac64c6ae69f14e'
            'd29a068937f9fdf0b82d314461f35c5f094b65f152afc57c593258d97fcfbd25')

prepare() {
  cd "${_realname/-/_}-${pkgver}"
  patch -p1 -i "${srcdir}"/0001-setup-check-msc-python.patch
}

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
}
