summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a57c6ca010b08e11e19696dd6be996111ef6899c (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
# Maintainer: Darius Niminenn <root@dnim.dev>
# Contributor: Chih-Hsuan Yen <yan12125@gmail.com>

pkgname=python-onnxoptimizer
pkgver=0.3.18
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-onnxruntime python-torchvision)
source=("onnx-optimizer::git+https://github.com/onnx/optimizer.git#tag=v$pkgver"
        "onnx-daquexian"::"git+https://github.com/daquexian/onnx.git")
sha256sums=('SKIP'
            'SKIP')
options=('debug')

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

  git submodule init
  git config submodule.third_party/onnx.url "$srcdir"/onnx-daquexian
  git -c protocol.file.allow=always submodule update third_party/onnx
}

build() {
  cd onnx-optimizer
  # Use system protobuf and protobuf-lite (https://github.com/onnx/optimizer/issues/38)
  CMAKE_ARGS="-DONNX_OPT_USE_SYSTEM_PROTOBUF=ON -DONNX_USE_PROTOBUF_SHARED_LIBS=ON -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-cpython-$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
}