# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-nodeenv
pkgver=1.8.0
pkgrel=4
pkgdesc="Node.js virtual environment builder"
url="https://github.com/ekalinin/nodeenv"
license=('BSD-3-Clause')
arch=(any)
depends=('python-setuptools' 'make')
makedepends=('python-build' 'python-installer' 'python-wheel')
optdepends=('nodejs: for --node=system')
checkdepends=('nodejs' 'python-pytest' 'python-coverage')
source=("$pkgname-$pkgver.tar.gz::https://github.com/ekalinin/nodeenv/archive/$pkgver.tar.gz"
	"replace-removed-pipes-import.patch"
	"fix-sys-import.patch")
sha512sums=('96dce219e00d3837b2b0083af9fe6d94ed4e3cd029e3da564263ad8656dcb9c52440c2df6a6954095e5cacd03e44437f08695603dea82c28122713045183014f'
            '074653554a8fb9504fc8f4b846c55ee3c47253964384991453a0c8b5aa1049c5e64f57edc9da3ade2cc054341d28c123eb7df68cd9b8bff26e47b50c20beb5ff'
            '041963448d15d2f6349af4e40779b5ba7abb6c1c83c5b03ffc3fea7003ab1dc258d98fd36994791cab057594dfdabb944007843113abf1e979c30e1d3bcda7ef')

prepare() {
  cd nodeenv-$pkgver
  patch -Np1 -i ${srcdir}/replace-removed-pipes-import.patch
  patch -Np1 -i ${srcdir}/fix-sys-import.patch
}

build() {
  cd nodeenv-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd nodeenv-$pkgver
  pytest
}

package() {
  cd nodeenv-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
