# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=flit
pkgbase=mingw-w64-python-${_realname}-core
pkgname=(${MINGW_PACKAGE_PREFIX}-python-$_realname-core)
pkgver=3.12.0
pkgrel=1
pkgdesc='Simplified packaging of Python modules (core backend) (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_repository_url='https://github.com/pypa/flit/'
msys2_references=(
  'purl: pkg:pypi/flit-core'
)
url='https://flit.pypa.io/'
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('1c80f34dd96992e7758b40423d2809f48f640ca285d0b7821825e50745ec3740')

build() {
  cd "${_realname}-${pkgver}/flit_core"

  PYTHONPATH=flit_core python -m flit_core.wheel
}

package() {
  cd "${_realname}-${pkgver}/flit_core"

  _pythonpath=`python -c "import sysconfig; print(sysconfig.get_path('platlib'))"`
  _site_packages="${pkgdir}$(cygpath ${_pythonpath})"
  mkdir -p "$_site_packages"
  python bootstrap_install.py -i"${_site_packages}" dist/flit_core-*.whl

  MSYS2_ARG_CONV_EXCL="-p" python -m compileall \
    -o 0 -o 1 -q -s"${pkgdir}" -p"/" "${pkgdir}${MINGW_PREFIX}/lib/python"*

  install -Dm 644 ../LICENSE "$pkgdir${MINGW_PREFIX}"/share/licenses/${_realname}-core/LICENSE
}
