# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=atomicwrites
pkgbase=python-${_realname}
pkgname=("python-${_realname}")
pkgver=1.4.0
pkgrel=2
pkgdesc="Atomic file writes on POSIX"
arch=('any')
url="https://github.com/untitaker/python-atomicwrites"
license=('MIT')
depends=('python')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
provides=("python3-${_realname}")
replaces=("python3-${_realname}")
conflicts=("python3-${_realname}")
source=("https://files.pythonhosted.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha512sums=('493fd15174880917650643db1fe85e2703add730189c23fcff11ceb87175f546b9251050ade506d0b48300e0f2a39ee5a4dcd4da8cb3e27680fd05553d6662cb')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  /usr/bin/python setup.py build
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"

  export PYTHONPATH=build;${PYTHONPATH}
  py.test
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"

  /usr/bin/python setup.py install --skip-build \
    --optimize=1 \
    --prefix=/usr \
    --root="${pkgdir}"

  install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
}
