|
| 1 | +TERMUX_PKG_HOMEPAGE=https://onnxruntime.ai/ |
| 2 | +TERMUX_PKG_DESCRIPTION="Cross-platform, high performance ML inferencing and training accelerator" |
| 3 | +TERMUX_PKG_LICENSE="MIT" |
| 4 | +TERMUX_PKG_MAINTAINER="@termux" |
| 5 | +TERMUX_PKG_VERSION="1.19.2" |
| 6 | +TERMUX_PKG_SRCURL=git+https://github.com/microsoft/onnxruntime |
| 7 | +TERMUX_PKG_DEPENDS="libc++, python3.8" |
| 8 | +TERMUX_PKG_BUILD_DEPENDS="python3.8-numpy" |
| 9 | +TERMUX_PKG_BUILD_IN_SRC=true |
| 10 | +TERMUX_PKG_PYTHON_COMMON_DEPS="wheel, build, packaging" |
| 11 | +# onnxruntime 1.20.0 dropped support for Python3.8 |
| 12 | +TERMUX_PKG_AUTO_UPDATE=false |
| 13 | + |
| 14 | +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" |
| 15 | +-Donnxruntime_ENABLE_PYTHON=ON |
| 16 | +-Donnxruntime_BUILD_SHARED_LIB=ON |
| 17 | +-DPYBIND11_USE_CROSSCOMPILING=TRUE |
| 18 | +-Donnxruntime_USE_NNAPI_BUILTIN=ON |
| 19 | +-Donnxruntime_USE_XNNPACK=ON |
| 20 | +" |
| 21 | + |
| 22 | +TERMUX_PYTHON_VERSION=3.8 |
| 23 | +TERMUX_PYTHON_HOME=$TERMUX_PREFIX/lib/python${TERMUX_PYTHON_VERSION} |
| 24 | +TERMUX_PYTHON_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python${TERMUX_PYTHON_VERSION/./}-crossenv-prefix-$TERMUX_ARCH |
| 25 | +TUR_AUTO_AUDIT_WHEEL=true |
| 26 | +TUR_AUDIT_WHEEL_NO_LIBS=true |
| 27 | +TUR_AUTO_BUILD_WHEEL=false |
| 28 | + |
| 29 | +source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh |
| 30 | + |
| 31 | +termux_step_post_get_source() { |
| 32 | + export PATH="$TERMUX_PREFIX/opt/python$TERMUX_PYTHON_VERSION/cross/bin:$PATH" |
| 33 | +} |
| 34 | + |
| 35 | +_setup_protobuf() { |
| 36 | + local _PROTOBUF_VERSION=21.12 |
| 37 | + local _PROTOBUF_ZIP=protoc-$_PROTOBUF_VERSION-linux-x86_64.zip |
| 38 | + local _PROTOBUF_FOLDER=${TERMUX_PKG_CACHEDIR}/protobuf-${_PROTOBUF_VERSION} |
| 39 | + |
| 40 | + if [ ! -d "$_PROTOBUF_FOLDER" ]; then |
| 41 | + termux_download \ |
| 42 | + https://github.com/protocolbuffers/protobuf/releases/download/v$_PROTOBUF_VERSION/$_PROTOBUF_ZIP \ |
| 43 | + $TERMUX_PKG_TMPDIR/$_PROTOBUF_ZIP \ |
| 44 | + 3a4c1e5f2516c639d3079b1586e703fc7bcfa2136d58bda24d1d54f949c315e8 |
| 45 | + |
| 46 | + rm -Rf "$TERMUX_PKG_TMPDIR/protoc-$_PROTOBUF_VERSION" |
| 47 | + unzip $TERMUX_PKG_TMPDIR/$_PROTOBUF_ZIP -d $TERMUX_PKG_TMPDIR/protobuf-$_PROTOBUF_VERSION |
| 48 | + mv "$TERMUX_PKG_TMPDIR/protobuf-$_PROTOBUF_VERSION" \ |
| 49 | + $_PROTOBUF_FOLDER |
| 50 | + fi |
| 51 | + |
| 52 | + export PATH="$_PROTOBUF_FOLDER/bin/:$PATH" |
| 53 | +} |
| 54 | + |
| 55 | +termux_step_pre_configure() { |
| 56 | + termux_setup_cmake |
| 57 | + termux_setup_ninja |
| 58 | + _setup_protobuf |
| 59 | + |
| 60 | + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPYTHON_EXECUTABLE=$(command -v python3)" |
| 61 | + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DONNX_CUSTOM_PROTOC_EXECUTABLE=$(command -v protoc)" |
| 62 | + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPython_NumPy_INCLUDE_DIR=$PYTHON_SITE_PKG/numpy/_core/include" |
| 63 | + |
| 64 | + local TERMUX_PKG_SRCDIR_SAVE="$TERMUX_PKG_SRCDIR" |
| 65 | + TERMUX_PKG_SRCDIR+="/cmake" |
| 66 | + termux_step_configure_cmake |
| 67 | + TERMUX_PKG_SRCDIR="$TERMUX_PKG_SRCDIR_SAVE" |
| 68 | + |
| 69 | + cmake --build . -j $TERMUX_PKG_MAKE_PROCESSES |
| 70 | +} |
| 71 | + |
| 72 | +termux_step_make() { |
| 73 | + python -m build --wheel --no-isolation |
| 74 | +} |
| 75 | + |
| 76 | +termux_step_make_install() { |
| 77 | + local _pyver="${TERMUX_PYTHON_VERSION//./}" |
| 78 | + local _wheel="onnxruntime-${TERMUX_PKG_VERSION}-cp${_pyver}-cp${_pyver}-linux_${TERMUX_ARCH}.whl" |
| 79 | + pip install --no-deps --prefix="$TERMUX_PREFIX" "$TERMUX_PKG_SRCDIR/dist/${_wheel}" |
| 80 | +} |
0 commit comments