# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=flit
pkgname="python-$_realname-core"
pkgver=3.12.0
pkgrel=1
pkgdesc='Simplified packaging of Python modules (core backend)'
arch=('any')
url='https://github.com/pypa/flit'
msys2_references=(
  'purl: pkg:pypi/flit-core'
)
license=('spdx:BSD-3-Clause')
depends=("python")
source=("${_realname}-$pkgver.tar.gz"::"$url/archive/$pkgver.tar.gz")
sha256sums=('c157ff92c01f4bb169182722ff76aadac113926b729215e91909021aa56e2ea3')

prepare() {
  cd "${_realname}-${pkgver}"
}

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}${_pythonpath}"
  mkdir -p "$_site_packages"
  python bootstrap_install.py -i"${_site_packages}" dist/flit_core-*.whl

  python -m compileall -o 0 -o 1 -q -s"${pkgdir}" -p"/" "${pkgdir}/usr/lib/python"*

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