# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=urllib3
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=1.26.6
pkgrel=1
pkgdesc="HTTP library with thread-safe connection pooling and file post support (mingw-w64)"
url='https://github.com/urllib3/urllib3'
license=('MIT')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-certifi"
         "${MINGW_PACKAGE_PREFIX}-python-idna")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-ndg-httpsclient"
             "${MINGW_PACKAGE_PREFIX}-python-pyasn1"
             "${MINGW_PACKAGE_PREFIX}-python-pyopenssl"
             #"${MINGW_PACKAGE_PREFIX}-python-pysocks"
             "${MINGW_PACKAGE_PREFIX}-python-mock")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-nose"
              "${MINGW_PACKAGE_PREFIX}-python-tornado"
              "${MINGW_PACKAGE_PREFIX}-python-coverage"
              "${MINGW_PACKAGE_PREFIX}-python-psutil")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/urllib3/urllib3/archive/${pkgver}.tar.gz")
sha256sums=('ab4582b44fbe33f3e3fc838e3d90dde7f68fa3697aeb075962e0ba4b93020327')

prepare() {
  cd ${srcdir}
  cp -r ${_realname}-${pkgver} python-build-${CARCH}
}

build() {
  cd "${srcdir}"
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd ${srcdir}/python-build-${CARCH}
  ${MINGW_PREFIX}/bin/python setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}"

  install -D -m644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}"/share/licenses/python-${_realname}/LICENSE.txt
}
