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

_realname=pelican
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=4.11.0
pkgrel=1
pkgdesc='Static site generator supporting Markdown and reStructuredText (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://getpelican.com/'
msys2_repository_url="https://github.com/getpelican/pelican"
msys2_references=(
  'archlinux: pelican'
  'purl: pkg:pypi/pelican'
)
license=('spdx:AGPL-3.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-blinker"
         "${MINGW_PACKAGE_PREFIX}-python-docutils"
         "${MINGW_PACKAGE_PREFIX}-python-feedgenerator"
         "${MINGW_PACKAGE_PREFIX}-python-jinja"
         "${MINGW_PACKAGE_PREFIX}-python-ordered-set"
         "${MINGW_PACKAGE_PREFIX}-python-pygments"
         "${MINGW_PACKAGE_PREFIX}-python-dateutil"
         "${MINGW_PACKAGE_PREFIX}-python-rich"
         "${MINGW_PACKAGE_PREFIX}-python-unidecode"
         "${MINGW_PACKAGE_PREFIX}-python-watchfiles"
         "${MINGW_PACKAGE_PREFIX}-python-tzdata")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-pdm-backend"
             "${MINGW_PACKAGE_PREFIX}-cc")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-cov"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-xdist")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-markdown: Markdown support")
options=(!strip)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz"
        '0001-pelican-4.11.0-dependencies-fix.patch')
sha256sums=('b90234487b818d391733acc1306b785934009749b1fc112b879df9bd89478bd8'
            '0d61a8ea8113a6c25fd6aada4b22e6fcf6088704d14c69a672df1333cc45936e')

prepare() {
  cd "pelican-${pkgver}"

  patch -p1 -i "${srcdir}"/0001-pelican-4.11.0-dependencies-fix.patch

  cd "${srcdir}"
  rm -rf "python-build-${MSYSTEM}" | true
  cp -r "pelican-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  PYTHONPATH="${srcdir}/python-build-${MSYSTEM}/build/lib" \
    ${MINGW_PREFIX}/bin/nosetests | true
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  # license
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}

# vim: ts=2 sw=2 et:
