# Maintainer: Chris Gorman <chrisjohgorman@gmail.com>
#

_realname=pygccxml
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.5.0
pkgrel=2
pkgdesc="Simple framework to navigate C++ declarations, using Python classes. (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/gccxml/pygccxml'
license=(Boost)
depends=("${MINGW_PACKAGE_PREFIX}-python"
	     "${MINGW_PACKAGE_PREFIX}-castxml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             'git')
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
options=('!strip')
# Using git as pygccxml has a symbolic link that causes tar to fail on the tarball
# the following is the git commit for tag pkgver
_commit='b67b26191192e2966712f28780e694348138b593'
source=("${_realname}"::"git+https://github.com/CastXML/${_realname}.git#commit=${_commit}")
sha256sums=('SKIP')

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}"
  cp -r "${_realname}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

#check() {
#  msg "Python test for ${MSYSTEM}"
#  cd "${srcdir}/python-build-${MSYSTEM}"
#
## The test command will usually depend upon what is contained in the tox.ini file
## or in the [testenv:py] section of the pyproject.toml file.
#  ${MINGW_PREFIX}/bin/python -m pytest
#}

package() {
  msg "Python install for ${MSYSTEM}"
  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.rst "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.rst"
}
