Skip to content

Commit 7a09b30

Browse files
committed
new package: python3.8-onnxruntime
1 parent f3ba469 commit 7a09b30

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed

tur-pypi-38/python3.8-numpy/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ TERMUX_PYTHON_VERSION=3.8
1717
TERMUX_PYTHON_HOME=$TERMUX_PREFIX/lib/python${TERMUX_PYTHON_VERSION}
1818
TERMUX_PYTHON_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python38-crossenv-prefix-$TERMUX_ARCH
1919
TUR_AUTO_AUDIT_WHEEL=true
20+
TUR_LIB_LICENSE_JSON="$TERMUX_PKG_BUILDER_DIR/licenses.json"
2021

2122
source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh
2223

@@ -29,3 +30,8 @@ termux_step_pre_configure() {
2930

3031
LDFLAGS+=" -lm"
3132
}
33+
34+
tur_install_wheel_license() {
35+
# Install the license of libopenblas
36+
cp $TERMUX_PREFIX/share/doc/libopenblas/copyright libopenblas-LICENSE
37+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"name": "openblas",
4+
"libs": [
5+
"libopenblas"
6+
],
7+
"licenses": [
8+
"libopenblas-LICENSE"
9+
]
10+
}
11+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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"
11+
--- a/cmake/onnxruntime_python.cmake
12+
+++ b/cmake/onnxruntime_python.cmake
13+
@@ -707,7 +707,6 @@
14+
15+
if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
16+
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS"
17+
- AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android"
18+
AND NOT onnxruntime_USE_ROCM
19+
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
20+
add_custom_command(
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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

Comments
 (0)