# Maintainer: Marcelo Duarte https://github.com/marcelotduarte

_realname=cx-logging
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.2.0
pkgrel=1
pkgdesc="Python and C interfaces for logging (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
msys2_references=(
  'pypi: cx-Logging'
)
license=('PSF')
url="https://github.com/anthony-tuininga/cx_Logging"
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" "${MINGW_PACKAGE_PREFIX}-cc")
options=('staticlibs' 'strip' '!debug')
source=(cx_Logging-${pkgver}.tar.gz::https://pypi.io/packages/source/c/cx_Logging/cx_Logging-${pkgver}.tar.gz
        0001-setup-remove-compiler-option.patch)
sha256sums=('bdbad6d2e6a0cc5bef962a34d7aa1232e88ea9f3541d6e2881675b5e7eab5502'
            'efd048e8cfee16056fd783e94f33d70281ae0b335713d6c1ba50c9941b61b6c6')

prepare() {
  cd "${srcdir}/cx_Logging-${pkgver}"

  # For clang
  if [[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]]; then
    patch -p1 -i "${srcdir}/0001-setup-remove-compiler-option.patch"
  fi

  cd "${srcdir}"
  rm -Rf python-${_realname}-${CARCH}
  cp -a cx_Logging-${pkgver} python-${_realname}-${CARCH}
}

package() {
  local _mingw_prefix=$(cygpath -wm ${MINGW_PREFIX})
  cd python-${_realname}-${CARCH}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1
}
