# Contributor: Brien Dieterle <briend@gmail.com>
# Contributor: Miloš Komarčević <miloskomarcevic@aim.com>

_realname=colour-science
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.4.6
pkgrel=2
pkgdesc="Python library for a multitude of colour science applications (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64')
url='https://www.colour-science.org'
msys2_repository_url='https://github.com/colour-science/colour'
msys2_references=(
  'aur: python-colour-science'
  'pypi: colour-science'
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-imageio"
         "${MINGW_PACKAGE_PREFIX}-python-numpy"
         "${MINGW_PACKAGE_PREFIX}-python-scipy"
         "${MINGW_PACKAGE_PREFIX}-python-typing_extensions")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-matplotlib"
            "${MINGW_PACKAGE_PREFIX}-python-networkx"
            "${MINGW_PACKAGE_PREFIX}-python-pandas"
            "${MINGW_PACKAGE_PREFIX}-python-tqdm"
            "${MINGW_PACKAGE_PREFIX}-python-trimesh")
conflicts=("${MINGW_PACKAGE_PREFIX}-python-${_realname//-science/}")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('be98c2c9b2a5caf0c443431f402599ca9e1cc7d944bb804156803bcc97af4cf0')

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"
}
