# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=testpath
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.4.4
pkgrel=1
pkgdesc="Test utilities for code working with files and commands (mingw-w64)"
url="https://pypi.python.org/pypi/testpath"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=(${_realname}-${pkgver}.tar.gz::https://github.com/jupyter/${_realname}/archive/${pkgver}.tar.gz
        "https://files.pythonhosted.org/packages/py2.py3/t/${_realname}/${_realname}-${pkgver}-py2.py3-none-any.whl")
sha256sums=('c52bf1a935e6283d30673f042915709ebc11d1e8a50d63f0c3305b6a8ee47933'
            'bfcf9411ef4bf3db7579063e0546938b1edda3d69f4e1fb8756991f5951f85d4')

prepare() {
  rm testpath/cli*.exe
  sed -i '/cli-32.exe/d' testpath-${pkgver}.dist-info/RECORD
  sed -i '/cli-64.exe/d' testpath-${pkgver}.dist-info/RECORD
  sed -i 's/shutil.copy(src, dst)/return/' testpath/commands.py
}

package() {
  local _py3_base=$(${MINGW_PREFIX}/bin/python -c "import sys;sys.stdout.write('.'.join(map(str, sys.version_info[:2])))")

  cd "${srcdir}/${_realname}"
  for _i in ./*; do
    install -Dm644 ${_i} "${pkgdir}${MINGW_PREFIX}/lib/python${_py3_base}/site-packages/${_realname}/${_i}"
  done

  _dist="${_realname}-${pkgver}.dist-info"
  cd "${srcdir}/${_dist}"
  for _i in ./*; do
    install -Dm644 $_i "${pkgdir}${MINGW_PREFIX}/lib/python${_py3_base}/site-packages/${_dist}/${_i}"
  done

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