# Maintainer: Antoine Martin <totaam@xpra.org>

_realname=pyopengl
_pyname=PyOpenGL
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.1.10
pkgrel=1
pkgdesc="PyOpenGL is the most common cross platform Python binding to OpenGL and related APIs (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://mcfletch.github.io/pyopengl/'
msys2_repository_url="https://github.com/mcfletch/pyopengl"
msys2_references=(
  'archlinux: python-opengl'
  'purl: pkg:pypi/pyopengl'
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-cython"
             "${MINGW_PACKAGE_PREFIX}-cc")
# Running the unit tests requires pygame,
# but since those fail unless you have a GPU, this is not enabled:
# checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pygame")
options=(!strip)
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('c4a02d6866b54eb119c8e9b3fb04fa835a95ab802dd96607ab4cdb0012df8335')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  # The tests fail without a GPU?
  # cd "${srcdir}/python-build-${MSYSTEM}"
  # ${MINGW_PREFIX}/bin/python -m pytest
  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

  rm -r "${pkgdir}"${MINGW_PREFIX}/lib/python*/site-packages/OpenGL/DLLS

  install -Dm644 license.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING"
}
