summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b9ae7fe54e29de6e1521e011ca934fadefa25c1e (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
# Maintainer: Chih-Hsuan Yen <yan12125@gmail.com>

pkgname=python-onnxoptimizer
pkgver=0.2.5
pkgdesc='ONNX model optimizer'
pkgrel=1
arch=(x86_64)
url='https://github.com/onnx/optimizer'
license=(MIT)
depends=(python python-onnx)
makedepends=(python-setuptools cmake pybind11 git)
checkdepends=(python-pytest python-nbval python-torchvision python-onnxruntime)
source=("onnx-optimizer::git+https://github.com/onnx/optimizer.git#tag=v$pkgver"
        "git+https://github.com/onnx/onnx.git")
sha256sums=('SKIP'
            'SKIP')

prepare() {
  cd onnx-optimizer
  sed -i '/pytest-runner/d' setup.py

  git submodule init
  git config submodule.third_party/onnx.url "$srcdir"/onnx
  git submodule update third_party/onnx
}

build() {
  cd onnx-optimizer
  # https://github.com/onnx/optimizer/issues/38
  CMAKE_ARGS="-DONNX_USE_LITE_PROTO=ON" python setup.py build
}

check() {
  cd onnx-optimizer
  pyver=$(python -c 'import sys; print(str(sys.version_info[0]) + "." + str(sys.version_info[1]))')
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-$pyver" pytest
}

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