# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=pyfasttextureutils
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}-git")
conflicts=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.r2.8fd8558
pkgrel=5
pkgdesc='Python module for quickly making certain modifications to images (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/LagoLunatic/PyFastTextureUtils"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "git"
             "patch"
             "${MINGW_PACKAGE_PREFIX}-cc")
_gitcommit=8fd8558f710c537d852ae407a5b316ab8bbb2337
source=("git+https://github.com/LagoLunatic/PyFastTextureUtils#commit=${_gitcommit}"
"minmax.patch")
sha256sums=('SKIP'
            'fc49c27aca6cfc6778dee41bca7aa2ef670117ed181e6eef7a0250bf2e16ab56')

pkgver() {
  cd $srcdir/PyFastTextureUtils
  printf "0.r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "PyFastTextureUtils" "python-build-${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  patch -Np2 -i ../minmax.patch
}

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