# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pyqt5-sip
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python-sip"
           "${MINGW_PACKAGE_PREFIX}-python-sip4")
replaces=("${MINGW_PACKAGE_PREFIX}-python-sip"
          "${MINGW_PACKAGE_PREFIX}-python-sip4")
pkgver=12.15.0
pkgrel=2
pkgdesc="The sip extension module provides support for the PyQt5 package (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/Python-SIP/sip"
msys2_references=(
  'archlinux: python-pyqt5-sip'
  'pypi: PyQt5-sip'
)
license=('spdx:BSD-2-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=(https://pypi.python.org/packages/source/P/PyQt5_sip/PyQt5_sip-${pkgver}.tar.gz)
sha256sums=('d23fdfcf363b5cedd9d39f8a9c5710e7d52804f5b08a58e91c638b36eafcb702')

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

build() {
  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 "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
