# Maintainer: Loïc Bartoletti <loic.bartoletti@oslandia.com>

_realname=pysfcgal
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=2.2.0
pkgrel=1
pkgdesc='Python SFCGAL binding (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://gitlab.com/SFCGAL/pysfcgal'
msys2_references=(
  'purl: pkg:pypi/pysfcgal'
)
license=('spdx:GPL-3.0-or-later')
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-sfcgal
    ${MINGW_PACKAGE_PREFIX}-python-cffi
)
makedepends=(
    ${MINGW_PACKAGE_PREFIX}-cc
    ${MINGW_PACKAGE_PREFIX}-python-build
    ${MINGW_PACKAGE_PREFIX}-python-installer
    ${MINGW_PACKAGE_PREFIX}-python-setuptools
)
source=(https://gitlab.com/SFCGAL/pysfcgal/-/archive/v${pkgver}/pysfcgal-v${pkgver}.tar.gz)
sha256sums=('b6bc1ec00d4b946fcf78c85bce111595a0a7ae6b5e463b973c20d566d747ea83')

build() {
  cp -r "${_realname}-v${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.md "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.md"
}
