# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=tornado
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=6.0.4
pkgrel=1
pkgdesc="open source version of the scalable, non-blocking web server and tools (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://www.tornadoweb.org/'
license=('Apache')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/tornadoweb/tornado/archive/v${pkgver}.tar.gz")
sha256sums=('bce8d8c57e9c91925d96b73fd3c5c0d38ba99000c8ee45fd5f30ce022ea90657')
noextract=("${_realname}-${pkgver}.tar.gz")

prepare() {
  # work around an issue with symbolic links in the tarball.
  bsdtar zxf ${_realname}-${pkgver}.tar.gz || true

  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"

  export TORNADO_EXTENSION=1
}

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

# We probably will need various prerequisits for this
#check() {
#  msg "Python test for ${CARCH}"
#  cd "${srcdir}/python-build-${CARCH}"
#  ${MINGW_PREFIX}/bin/python setup.py check
#}

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
}
