Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tur-pypi-38/python3.8-numpy/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ TERMUX_PYTHON_VERSION=3.8
TERMUX_PYTHON_HOME=$TERMUX_PREFIX/lib/python${TERMUX_PYTHON_VERSION}
TERMUX_PYTHON_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python38-crossenv-prefix-$TERMUX_ARCH
TUR_AUTO_AUDIT_WHEEL=true
TUR_LIB_LICENSE_JSON="$TERMUX_PKG_BUILDER_DIR/licenses.json"

source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh

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

LDFLAGS+=" -lm"
}

tur_install_wheel_license() {
# Install the license of libopenblas
cp $TERMUX_PREFIX/share/doc/libopenblas/copyright libopenblas-LICENSE
}
11 changes: 11 additions & 0 deletions tur-pypi-38/python3.8-numpy/licenses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"name": "openblas",
"libs": [
"libopenblas"
],
"licenses": [
"libopenblas-LICENSE"
]
}
]
20 changes: 20 additions & 0 deletions tur-pypi-38/python3.8-onnxruntime/0001-build-providers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- a/cmake/onnxruntime_providers_cpu.cmake
+++ b/cmake/onnxruntime_providers_cpu.cmake
@@ -225,7 +225,6 @@

if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS"
- AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android"
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
file(GLOB onnxruntime_providers_shared_cc_srcs CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/core/providers/shared/*.h"
--- a/cmake/onnxruntime_python.cmake
+++ b/cmake/onnxruntime_python.cmake
@@ -707,7 +707,6 @@

if (NOT onnxruntime_MINIMAL_BUILD AND NOT onnxruntime_EXTENDED_MINIMAL_BUILD
AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS|visionOS"
- AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android"
AND NOT onnxruntime_USE_ROCM
AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
add_custom_command(
83 changes: 83 additions & 0 deletions tur-pypi-38/python3.8-onnxruntime/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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.19.2"
TERMUX_PKG_SRCURL=git+https://github.com/microsoft/onnxruntime
TERMUX_PKG_DEPENDS="libc++, python3.8"
TERMUX_PKG_BUILD_DEPENDS="python3.8-numpy"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_PYTHON_COMMON_DEPS="wheel, build, packaging"
# onnxruntime 1.20.0 dropped support for Python3.8
TERMUX_PKG_AUTO_UPDATE=false

TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-Donnxruntime_ENABLE_PYTHON=ON
-Donnxruntime_BUILD_SHARED_LIB=ON
-DPYBIND11_USE_CROSSCOMPILING=TRUE
-Donnxruntime_USE_NNAPI_BUILTIN=ON
-Donnxruntime_USE_XNNPACK=ON
"

TERMUX_PYTHON_VERSION=3.8
TERMUX_PYTHON_HOME=$TERMUX_PREFIX/lib/python${TERMUX_PYTHON_VERSION}
TERMUX_PYTHON_CROSSENV_PREFIX=$TERMUX_PKG_BUILDDIR/python${TERMUX_PYTHON_VERSION/./}-crossenv-prefix-$TERMUX_ARCH
TUR_AUTO_AUDIT_WHEEL=true
TUR_AUDIT_WHEEL_NO_LIBS=true
TUR_AUTO_BUILD_WHEEL=false

source $TERMUX_SCRIPTDIR/common-files/tur_build_wheel.sh

termux_step_post_get_source() {
export PATH="$TERMUX_PREFIX/opt/python$TERMUX_PYTHON_VERSION/cross/bin:$PATH"
}

_setup_protobuf() {
local _PROTOBUF_VERSION=21.12
local _PROTOBUF_ZIP=protoc-$_PROTOBUF_VERSION-linux-x86_64.zip
local _PROTOBUF_FOLDER=${TERMUX_PKG_CACHEDIR}/protobuf-${_PROTOBUF_VERSION}

if [ ! -d "$_PROTOBUF_FOLDER" ]; then
termux_download \
https://github.com/protocolbuffers/protobuf/releases/download/v$_PROTOBUF_VERSION/$_PROTOBUF_ZIP \
$TERMUX_PKG_TMPDIR/$_PROTOBUF_ZIP \
3a4c1e5f2516c639d3079b1586e703fc7bcfa2136d58bda24d1d54f949c315e8

rm -Rf "$TERMUX_PKG_TMPDIR/protoc-$_PROTOBUF_VERSION"
unzip $TERMUX_PKG_TMPDIR/$_PROTOBUF_ZIP -d $TERMUX_PKG_TMPDIR/protobuf-$_PROTOBUF_VERSION
mv "$TERMUX_PKG_TMPDIR/protobuf-$_PROTOBUF_VERSION" \
$_PROTOBUF_FOLDER
fi

export PATH="$_PROTOBUF_FOLDER/bin/:$PATH"
}

termux_step_pre_configure() {
termux_setup_cmake
termux_setup_ninja
_setup_protobuf

TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPYTHON_EXECUTABLE=$(command -v python3)"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPYTHON_INCLUDE_DIR=$TERMUX_PREFIX/include/python$TERMUX_PYTHON_VERSION"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPython_EXECUTABLE=$(command -v python3)"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPython_INCLUDE_DIR=$TERMUX_PREFIX/include/python$TERMUX_PYTHON_VERSION"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DPython_NumPy_INCLUDE_DIR=$PYTHON_SITE_PKG/numpy/core/include"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DONNX_CUSTOM_PROTOC_EXECUTABLE=$(command -v protoc)"

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 . -j $TERMUX_PKG_MAKE_PROCESSES
}

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}"
}