Skip to content

Commit ebec4ea

Browse files
committed
new package: python3.12-onnxruntime
1 parent b24ea5e commit ebec4ea

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- a/cmake/onnxruntime_providers_cpu.cmake
2+
+++ b/cmake/onnxruntime_providers_cpu.cmake
3+
@@ -225,7 +225,6 @@
4+
5+
if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
6+
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS"
7+
- AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android"
8+
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
9+
file(GLOB onnxruntime_providers_shared_cc_srcs CONFIGURE_DEPENDS
10+
"${ONNXRUNTIME_ROOT}/core/providers/shared/*.h"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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_REVISION=1
7+
TERMUX_PKG_SRCURL=git+https://github.com/microsoft/onnxruntime
8+
TERMUX_PKG_DEPENDS="libc++, python"
9+
TERMUX_PKG_BUILD_DEPENDS="python-numpy"
10+
TERMUX_PKG_BUILD_IN_SRC=true
11+
TERMUX_PKG_PYTHON_COMMON_DEPS="wheel, build, packaging"
12+
TERMUX_PKG_AUTO_UPDATE=true
13+
TERMUX_PKG_UPDATE_TAG_TYPE="latest-release-tag"
14+
15+
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
16+
-Donnxruntime_ENABLE_PYTHON=ON
17+
-Donnxruntime_BUILD_SHARED_LIB=OFF
18+
-DPYBIND11_USE_CROSSCOMPILING=TRUE
19+
-Donnxruntime_USE_NNAPI_BUILTIN=ON
20+
-Donnxruntime_USE_XNNPACK=ON
21+
"
22+
23+
TERMUX_PYTHON_VERSION=3.12
24+
TERMUX_PYTHON_HOME=$TERMUX_PREFIX/lib/python${TERMUX_PYTHON_VERSION}
25+
TERMUX_PYTHON_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python${TERMUX_PYTHON_VERSION/./}-crossenv-prefix-$TERMUX_ARCH
26+
TUR_AUTO_AUDIT_WHEEL=true
27+
TUR_AUDIT_WHEEL_NO_LIBS=true
28+
TUR_AUTO_BUILD_WHEEL=false
29+
30+
source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh
31+
32+
_setup_protobuf() {
33+
local _PROTOBUF_VERSION=21.12
34+
local _PROTOBUF_ZIP=protoc-$_PROTOBUF_VERSION-linux-x86_64.zip
35+
local _PROTOBUF_FOLDER=${TERMUX_PKG_CACHEDIR}/protobuf-${_PROTOBUF_VERSION}
36+
37+
if [ ! -d "$_PROTOBUF_FOLDER" ]; then
38+
termux_download \
39+
https://github.com/protocolbuffers/protobuf/releases/download/v$_PROTOBUF_VERSION/$_PROTOBUF_ZIP \
40+
$TERMUX_PKG_TMPDIR/$_PROTOBUF_ZIP \
41+
3a4c1e5f2516c639d3079b1586e703fc7bcfa2136d58bda24d1d54f949c315e8
42+
43+
rm -Rf "$TERMUX_PKG_TMPDIR/protoc-$_PROTOBUF_VERSION"
44+
unzip $TERMUX_PKG_TMPDIR/$_PROTOBUF_ZIP -d $TERMUX_PKG_TMPDIR/protobuf-$_PROTOBUF_VERSION
45+
mv "$TERMUX_PKG_TMPDIR/protobuf-$_PROTOBUF_VERSION" \
46+
$_PROTOBUF_FOLDER
47+
fi
48+
49+
export PATH="$_PROTOBUF_FOLDER/bin/:$PATH"
50+
}
51+
52+
termux_step_pre_configure() {
53+
termux_setup_cmake
54+
termux_setup_ninja
55+
_setup_protobuf
56+
57+
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPYTHON_EXECUTABLE=$(command -v python3)"
58+
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DONNX_CUSTOM_PROTOC_EXECUTABLE=$(command -v protoc)"
59+
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPython_NumPy_INCLUDE_DIR=$PYTHON_SITE_PKG/numpy/_core/include"
60+
61+
local TERMUX_PKG_SRCDIR_SAVE="$TERMUX_PKG_SRCDIR"
62+
TERMUX_PKG_SRCDIR+="/cmake"
63+
termux_step_configure_cmake
64+
TERMUX_PKG_SRCDIR="$TERMUX_PKG_SRCDIR_SAVE"
65+
66+
cmake --build .
67+
}
68+
69+
termux_step_make() {
70+
python -m build --wheel --no-isolation
71+
}
72+
73+
termux_step_make_install() {
74+
local _pyver="${TERMUX_PYTHON_VERSION//./}"
75+
local _wheel="onnxruntime-${TERMUX_PKG_VERSION}-cp${_pyver}-cp${_pyver}-linux_${TERMUX_ARCH}.whl"
76+
pip install --no-deps --prefix="$TERMUX_PREFIX" "$TERMUX_PKG_SRCDIR/dist/${_wheel}"
77+
}

0 commit comments

Comments
 (0)