# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=python-js2py
pkgver=0.72
_commit=70fe4f557e957db082ee49f8e9b4cf4ac80071ef
pkgrel=5
pkgdesc="JavaScript to Python Translator & JavaScript interpreter written in 100% pure Python"
url="https://github.com/PiotrDabkowski/Js2Py"
license=('MIT')
arch=('any')
depends=('python-six' 'python-pyjsparser')
makedepends=('git' 'python-setuptools' 'python-tzlocal')
checkdepends=('npm' 'python-numpy')
optdepends=('python-tzlocal: for local timezone support')
source=("git+https://github.com/PiotrDabkowski/Js2Py.git#commit=$_commit"
        "js2py-opt-tzlocal.patch::https://github.com/PiotrDabkowski/Js2Py/pull/293.patch"
        "js2py-python3.12.patch::https://github.com/PiotrDabkowski/Js2Py/pull/327.patch")
sha512sums=('3d2e7f21fbeabe40011be53c2f7231260cf65af13c589ead194ebc45d1f4a09eb506af076e8488017904038375171ecc1a4168910f97e84aa3a390633746a2cc'
            'db4fce5b0b26cc89346347719f7feb8da65119ef54504f6475d7a52f0dbb6483c26ff259a1b5c54c98422057e64debad5d2d92585e1acfd1a1c67f301d6a328c'
            '0d9d77461c3f95d561230473a83155ea7e202db2837dac0f989731dfe74d4c5d9bbbd625e6991ec30eadb6b6d6c16a4980ab3e17e189575bcaa431aac6492c3d')

prepare() {
  cd Js2Py
  # https://github.com/PiotrDabkowski/Js2Py/pull/293
  patch --forward --strip=1 --input=../js2py-opt-tzlocal.patch
  # https://github.com/PiotrDabkowski/Js2Py/pull/327
  patch --forward --strip=1 --input=../js2py-python3.12.patch
}

build() {
  cd Js2Py
  python setup.py build
}

check() {
  cd Js2Py
  python simple_test.py
}

package() {
  cd Js2Py
  python setup.py install --root="$pkgdir" --optimize=1
  install -Dm644 LICENSE.md -t "$pkgdir"/usr/share/licenses/$pkgname/
}
