# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=networkx
pkgbase=mingw-w64-python3-${_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=2.5
pkgrel=1
pkgdesc="High-productivity software for complex networks (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('BSD')
url="https://github.com/networkx/networkx"
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-decorator")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-numpy"
            "${MINGW_PACKAGE_PREFIX}-python-scipy"
            "${MINGW_PACKAGE_PREFIX}-python-pyparsing"
            "${MINGW_PACKAGE_PREFIX}-python-yaml")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-nose")
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/networkx/networkx/archive/${_realname}-${pkgver}.tar.gz")
sha256sums=('db3adff2eaf91d4eba16268504ef12bed920d4dc2bd5e1e3812d8fd11d166a73')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${_realname}-${pkgver}" "python-build-${CARCH}"
}

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

check() {
  cd ${srcdir}/python-build-${CARCH}
  ${MINGW_PREFIX}/bin/nosetests
}

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

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