# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_realname=docxtpl
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-$_realname")
pkgver=0.20.1
pkgrel=1
pkgdesc="Use a docx as a jinja2 template (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://docxtpl.readthedocs.io"
msys2_repository_url="https://github.com/elapouya/python-docx-template"
msys2_references=(
  'purl: pkg:pypi/docxtpl'
)
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-docx"
         "${MINGW_PACKAGE_PREFIX}-python-docxcompose"
         "${MINGW_PACKAGE_PREFIX}-python-jinja"
         "${MINGW_PACKAGE_PREFIX}-python-black"
         "${MINGW_PACKAGE_PREFIX}-twine")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-poetry-core")
source=("https://pypi.io/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz"
        "${msys2_repository_url}/raw/refs/heads/master/LICENSE.txt")
sha256sums=('5bab05a2c60b225c730ce18e9e2d40d748b4a12f599e150badbcb659088a51d4'
            '9b872a8a070b8ad329c4bd380fb1bf0000f564c75023ec8e1e6803f15364b9e9')

build() {
  cp -r "${_realname}-${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 "${srcdir}"/LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
  install -Dm644 README.rst "${pkgdir}${MINGW_PREFIX}/share/doc/python-${_realname}/README.rst"
}

# vim:set ts=2 sw=2 et:
