# Maintainer: @naveen521kk on Github, Naveen M K <naveen521kk@gmail.com>

_pyname=moderngl-window
_realname=moderngl-window
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.3.0
pkgrel=1
pkgdesc='A cross platform helper library for ModernGL making window creation and resource loading simple (mingw-w64)'
arch=('any')
url="https://github.com/moderngl/moderngl_window"
license=('MIT')
depends=(
  "${MINGW_PACKAGE_PREFIX}-python" 
  "${MINGW_PACKAGE_PREFIX}-python-moderngl"
  "${MINGW_PACKAGE_PREFIX}-python-numpy"
  "${MINGW_PACKAGE_PREFIX}-python-pillow"
  "${MINGW_PACKAGE_PREFIX}-python-pyglet"
  "${MINGW_PACKAGE_PREFIX}-python-pyrr"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-python-setuptools" 
)
source=("${_pyname}-${pkgver}.tar.gz::https://github.com/moderngl/moderngl-window/archive/refs/tags/${pkgver}.tar.gz")
sha256sums=('4ff5d473ea51cb86a4b72a20de1cb2cf037c578c391508a44009cd8a4f6cc68b')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_pyname//_/-}-$pkgver" "python-build-${CARCH}"
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
