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

_realname=setuptools-rust
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=0.11.6
pkgrel=1
pkgdesc="Compile and distribute Python extensions written in rust as easily as if they were written in C (mingw-w64)"
url='https://github.com/PyO3/setuptools-rust'
license=('MIT')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
depends=("${MINGW_PACKAGE_PREFIX}-rust"
         "${MINGW_PACKAGE_PREFIX}-python-toml"
         "${MINGW_PACKAGE_PREFIX}-python-semantic-version"
         "${MINGW_PACKAGE_PREFIX}-python-setuptools")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools-scm"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
source=("https://github.com/PyO3/setuptools-rust/archive/v$pkgver/$_realname-$pkgver.tar.gz")
sha256sums=('0c22494070035f43b8b1578dc28d247e3efaeea401fd67b7d062ebc5ce800786')

prepare() {
  cd "${srcdir}/${_realname}-$pkgver"
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

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

  ${MINGW_PREFIX}/bin/python setup.py build
}

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

  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

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