summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: cfb5b6b1de9c77edd451209f02e4d97713002e4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Maintainer: Chih-Hsuan Yen <yan12125@archlinux.org>

pkgname=python-tf2onnx
epoch=1
pkgver=1.12.1
pkgrel=1
pkgdesc='Convert TensorFlow models to ONNX'
arch=(any)
url='https://github.com/onnx/tensorflow-onnx'
license=(MIT)
depends=(python python-tensorflow python-numpy python-onnx python-requests python-six)
makedepends=(python-setuptools python-build python-installer python-wheel)
checkdepends=(python-pytest python-graphviz python-parameterized python-yaml python-onnxruntime)
source=("https://github.com/onnx/tensorflow-onnx/archive/v$pkgver/tf2onnx-v$pkgver.tar.gz"
        "onnxruntime.diff")
sha256sums=('77529a4eaa6d50a572020a023af93047b942fbde5cf4447878014037481b7f5f'
            '7e8ab46940aff7cac8d535436c8e201f37c66637416ae9b795706a4c3dd01232')

prepare() {
  cd tensorflow-onnx-$pkgver

  sed -i -r 's#--cov\S+##' setup.cfg
  sed -i "s#'pytest-runner'##" setup.py

  # The latest upstream tag may not sync with the version file
  echo $pkgver > VERSION_NUMBER

  patch -Np1 -i ../onnxruntime.diff
}

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

check() {
  cd tensorflow-onnx-$pkgver
  # Apparently the failure is caused by new operators in TensorFlow lite 2.10.0 [1][2]
  # [1] https://github.com/tensorflow/tensorflow/commit/cac33fd25c1df270758a66fd0dadba5c973abf9a
  # [2] https://github.com/tensorflow/tensorflow/commit/12f38bba6659b417f5408f24ebf267e05c738beb
  PYTHONPATH="$PWD" pytest tests -k 'not test_unsorted_segment_ops'
}

package() {
  cd tensorflow-onnx-$pkgver
  python -m installer --destdir="$pkgdir" --compile-bytecode 0 --compile-bytecode 1 --compile-bytecode 2 dist/*.whl
  install -Dm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}