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

_realname=pyopenssl
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=20.0.1
pkgrel=1
pkgdesc="Python wrapper module around the OpenSSL library (mingw-w64)"
url='https://pypi.python.org/pypi/pyOpenSSL'
license=('LGPL2.1')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
depends=("${MINGW_PACKAGE_PREFIX}-openssl"
         "${MINGW_PACKAGE_PREFIX}-python-cryptography"
         "${MINGW_PACKAGE_PREFIX}-python-six")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest-runner")
source=("https://pypi.io/packages/source/p/pyOpenSSL/pyOpenSSL-${pkgver}.tar.gz")
sha256sums=('4c231c759543ba02560fcd2480c48dcec4dae34c9da7d3747c508227e0624b51')

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

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

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

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