# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Spyros Stathopoulos <foucault.online@gmail.com>
# Contributor: richli <rich at dranek dot com>
# Contributor: rememberthemer <rememberthemer@_GMAIL_DOT_COM_>

_pkg=netCDF4
pkgname=python-${_pkg,,}
pkgver=1.6.5
pkgrel=1
pkgdesc="Python/NumPy interface to the netCDF C library"
arch=(x86_64 aarch64)
url="https://unidata.github.io/netcdf4-python"
license=(MIT)
depends=(python-numpy python-cftime netcdf python-certifi)
makedepends=(cython python-setuptools)
source=(https://files.pythonhosted.org/packages/source/${_pkg::1}/${_pkg}/${_pkg}-${pkgver}.tar.gz)
sha256sums=('824881d0aacfde5bd982d6adedd8574259c85553781e7b83e0ce82b890bfa0ef')

build() {
  cd ${_pkg}-${pkgver}
  USE_NCCONFIG=1 python setup.py build
}

check() {
  cd ${_pkg}-${pkgver}/test
  local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
  NO_NET=1 PYTHONPATH="../build/lib.linux-${CARCH}-cpython-${python_version/./}" python -B ./run_all.py
}

package() {
  cd ${_pkg}-${pkgver}
  USE_NCCONFIG=1 python setup.py install --prefix=/usr --root="${pkgdir}" --skip-build --optimize=2
  install -Dm644 LICENSE -t "${pkgdir}"/usr/share/licenses/${pkgname}
}
