# Maintainer: Dirk Stolle

_realname=passagemath-modules
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=10.6.47
pkgrel=2
pkgdesc="passagemath: Vectors, matrices, tensors, vector spaces, affine spaces, modules and algebras, additive groups, quadratic forms, homology, coding theory, matroids (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/passagemath/passagemath'
msys2_references=(
  'purl: pkg:pypi/passagemath-modules'
)
license=('spdx:GPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-gsl"
         "${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-cysignals"
         "${MINGW_PACKAGE_PREFIX}-python-gmpy2"
         "${MINGW_PACKAGE_PREFIX}-python-memory-allocator"
         "${MINGW_PACKAGE_PREFIX}-python-mpmath"
         "${MINGW_PACKAGE_PREFIX}-python-passagemath-categories"
         "${MINGW_PACKAGE_PREFIX}-python-passagemath-environment")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cython"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-jinja"
             "${MINGW_PACKAGE_PREFIX}-python-numpy"
             "${MINGW_PACKAGE_PREFIX}-python-passagemath-setup"
             "${MINGW_PACKAGE_PREFIX}-python-pkgconfig"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
optdepends=(
  # Optional dependencies which are not packaged yet are commented out.
  # "${MINGW_PACKAGE_PREFIX}-python-fpyll"
  "${MINGW_PACKAGE_PREFIX}-python-numpy"
  # passagemath-flint is currently only available on non-clang builds.
  $([[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]] || echo "${MINGW_PACKAGE_PREFIX}-python-passagemath-flint")
  # "${MINGW_PACKAGE_PREFIX}-python-passagemath-flint"
  # "${MINGW_PACKAGE_PREFIX}-python-passagemath-linbox"
  # "${MINGW_PACKAGE_PREFIX}-python-passagemath-m4ri-m4rie"
  # "${MINGW_PACKAGE_PREFIX}-python-passagemath-meataxe"
  # passagemath-ntl is currently only available on non-clang builds.
  $([[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]] || echo "${MINGW_PACKAGE_PREFIX}-python-passagemath-ntl")
  # "${MINGW_PACKAGE_PREFIX}-python-passagemath-pari"
)
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('207195dd7578c83867e84c151f35ed92a0a2fbe598651a5913d5f20bf4b4c84d')

build() {
  cp -r "${_realname/-/_}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

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

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