# Maintainer: Sebastian Ehlert <awvwgk@disroot.org>

_realname=ford
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=7.0.12
pkgrel=1
pkgdesc="FORD, standing for FORtran Documenter, is an automatic documentation generator for modern Fortran programs (mingw-w64)"
license=('spdx:GPL-3.0-or-later')
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'anitya: 223245'
  'purl: pkg:pypi/ford'
)
msys2_repository_url='https://github.com/Fortran-FOSS-Programmers/ford'
url='https://forddocs.readthedocs.io/'
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-beautifulsoup4"
         "${MINGW_PACKAGE_PREFIX}-python-graphviz"
         "${MINGW_PACKAGE_PREFIX}-python-jinja"
         "${MINGW_PACKAGE_PREFIX}-python-markdown"
         "${MINGW_PACKAGE_PREFIX}-python-markdown-include"
         "${MINGW_PACKAGE_PREFIX}-python-markdown-math"
         "${MINGW_PACKAGE_PREFIX}-python-pcpp"
         "${MINGW_PACKAGE_PREFIX}-python-pygments"
         "${MINGW_PACKAGE_PREFIX}-python-rich"
         "${MINGW_PACKAGE_PREFIX}-python-toposort"
         "${MINGW_PACKAGE_PREFIX}-python-tqdm")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm-git-archive")
options=(!strip)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('96a3bec14f23c62db8a9c8072ebe1b6d6e043a315361923146e9cd459f913c59')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  sed -i -e 's|~=|>=|' pyproject.toml
}

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