# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=python-json-logger
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=4.0.0
pkgrel=1
pkgdesc="A python library adding a json log formatter (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-json-logger'
  'gentoo: dev-python/python-json-logger'
  'purl: pkg:pypi/python-json-logger'
)
msys2_repository_url='https://github.com/nhairs/python-json-logger'
msys2_changelog_url='https://nhairs.github.io/python-json-logger/latest/changelog/'
url='https://nhairs.github.io/python-json-logger/latest/'
license=('spdx:BSD-2-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname//-/_}/${_realname//-/_}-${pkgver}.tar.gz")
sha256sums=('f58e68eb46e1faed27e0f574a55a0455eecd7b8a5b88b85a784519ba3cff047f')

build() {
  cp -r "${_realname//-/_}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
