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

_realname=tinyaes
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.0.1
_tinyaesc_ver=1.0.0
pkgrel=1
pkgdesc='tiny-AES-c wrapper in Cython (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/naufraghi/tinyaes-py"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" "${MINGW_PACKAGE_PREFIX}-cython")
options=('!emptydirs')
source=("https://github.com/naufraghi/tinyaes-py/archive/refs/tags/v$pkgver.tar.gz"
"https://github.com/kokke/tiny-AES-c/archive/v${_tinyaesc_ver}.tar.gz")
sha256sums=('6c6b17a1e75efebe8b5c2a70b7a23fed329be1672e3bac5f6ee2361b2aabc20b'
            '61fd99ac95df30e9ab39d6cdd41e88909b2eaf9b9806f23aa235485ac0bed2fd')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-py-${pkgver}" "python-build-${CARCH}"
  cp -r -T "tiny-AES-c-${_tinyaesc_ver}" "python-build-${CARCH}/tiny-AES-c"
}

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