Files
termux-packages/packages/python-onnxruntime/build.sh
termux-pacman-bot 46a7edf28c bump(main/libprotobuf): 32.0
- Includes revision-bumps of all reverse dependencies; only one package, `apache-orc`, has a build failure because of newer `libprotobuf`. Its patch is copied and pasted from this PR: https://github.com/apache/orc/pull/2316

- `protobuf-static` is also bumped. It is an orphaned package and there have been, in the past several months since
  https://github.com/termux/termux-packages/pull/24131, **no known cases of anyone encountering any issues for which they need `protobuf-static` anymore**. This strongly suggests that the **new `libandroid-stub` invented by twaik** that I helped with https://github.com/termux/termux-packages/pull/23712 is probably a completely successful workaround in Android to this upstream `libprotobuf` issue: https://github.com/protocolbuffers/protobuf/issues/5254. However, because the original bug is very rare and only affects a very few Android devices, and among those few Android device where it is reproducible, there are some subtle variations in the content of the protobuf error message, for the time being, I think it is probably a good idea to keep `protobuf-static` unchanged, and eventually, maybe in 1 year from now, if still nobody has ever needed `protobuf-static` at that time, it can be completely disabled.
2025-09-10 13:39:49 +00:00

60 lines
1.9 KiB
Bash

TERMUX_PKG_HOMEPAGE=https://onnxruntime.ai/
TERMUX_PKG_DESCRIPTION="Cross-platform, high performance ML inferencing and training accelerator"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="1.22.2"
TERMUX_PKG_REVISION=2
TERMUX_PKG_SRCURL=git+https://github.com/microsoft/onnxruntime
TERMUX_PKG_DEPENDS="abseil-cpp, libc++, protobuf, libre2, python"
TERMUX_PKG_BUILD_DEPENDS="python-numpy"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_PYTHON_COMMON_DEPS="wheel, build, packaging"
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_UPDATE_TAG_TYPE="latest-release-tag"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
-Donnxruntime_ENABLE_PYTHON=ON
-Donnxruntime_BUILD_SHARED_LIB=OFF
-DPYBIND11_USE_CROSSCOMPILING=TRUE
-Donnxruntime_USE_NNAPI_BUILTIN=ON
-Donnxruntime_USE_XNNPACK=ON
"
termux_step_pre_configure() {
CPPFLAGS+=" -Wno-unused-variable"
termux_setup_cmake
termux_setup_ninja
termux_setup_protobuf
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPYTHON_EXECUTABLE=$(command -v python3)"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DONNX_CUSTOM_PROTOC_EXECUTABLE=$(command -v protoc)"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPython_NumPy_INCLUDE_DIR=$TERMUX_PREFIX/lib/python$TERMUX_PYTHON_VERSION/site-packages/numpy/_core/include"
local TERMUX_PKG_SRCDIR_SAVE="$TERMUX_PKG_SRCDIR"
TERMUX_PKG_SRCDIR+="/cmake"
termux_step_configure_cmake
TERMUX_PKG_SRCDIR="$TERMUX_PKG_SRCDIR_SAVE"
cmake --build .
}
termux_step_make() {
python -m build --wheel --no-isolation
}
termux_step_make_install() {
local _pyver="${TERMUX_PYTHON_VERSION//./}"
local _wheel="onnxruntime-${TERMUX_PKG_VERSION}-cp${_pyver}-cp${_pyver}-linux_${TERMUX_ARCH}.whl"
pip install --no-deps --prefix="$TERMUX_PREFIX" "$TERMUX_PKG_SRCDIR/dist/${_wheel}"
}
termux_step_create_debscripts() {
cat <<- EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh
echo "Installing dependencies through pip..."
pip3 install onnxruntime
EOF
}