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
88 changes: 33 additions & 55 deletions tur-pypi-312/python3.12-polars/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ TERMUX_PKG_HOMEPAGE=https://github.com/pola-rs/polars
TERMUX_PKG_DESCRIPTION="Dataframes powered by a multithreaded, vectorized query engine, written in Rust"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux-user-repository"
TERMUX_PKG_VERSION="1.18.0"
TERMUX_PKG_VERSION="1.19.0"
TERMUX_PKG_SRCURL=https://github.com/pola-rs/polars/releases/download/py-$TERMUX_PKG_VERSION/polars-$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=5c2f119555ae8d822a5322509c6abd91601a8931115d2e4c3fff13fadf39e877
TERMUX_PKG_SHA256=b52ada5c43fcdadf64f282522198c5549ee4e46ea57d236a4d7e572643070d9d
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_DEPENDS="libc++, python"
TERMUX_PKG_PYTHON_COMMON_DEPS="wheel"
Expand Down Expand Up @@ -52,62 +52,38 @@ termux_step_pre_configure() {
: "${CARGO_HOME:=$HOME/.cargo}"
export CARGO_HOME


rm -rf $CARGO_HOME/registry/src/*/cmake-*
rm -rf $CARGO_HOME/registry/src/*/jemalloc-sys-*
rm -rf $CARGO_HOME/registry/src/*/arboard-*
cargo fetch --target "${CARGO_TARGET_NAME}"

local p="cmake-0.1.50-src-lib.rs.diff"
local d
for d in $CARGO_HOME/registry/src/*/cmake-*; do
patch --silent -p1 -d ${d} \
< "$TERMUX_PKG_BUILDER_DIR/${p}"
done

p="jemalloc-sys-0.5.4+5.3.0-patched-src-lib.rs.diff"
for d in $CARGO_HOME/registry/src/*/jemalloc-sys-*; do
patch --silent -p1 -d ${d} < "$TERMUX_PKG_BUILDER_DIR/${p}"
done

p="arboard-dummy-platform.diff"
for d in $CARGO_HOME/registry/src/*/arboard-*; do
patch --silent -p1 -d ${d} < "$TERMUX_PKG_BUILDER_DIR/${p}"
done

local _CARGO_TARGET_LIBDIR="target/${CARGO_TARGET_NAME}/release/deps"
mkdir -p $_CARGO_TARGET_LIBDIR

mv $TERMUX_PREFIX/lib/libz.so.1{,.tmp}
mv $TERMUX_PREFIX/lib/libz.so{,.tmp}

ln -sfT $(readlink -f $TERMUX_PREFIX/lib/libz.so.1.tmp) \
$_CARGO_TARGET_LIBDIR/libz.so.1
ln -sfT $(readlink -f $TERMUX_PREFIX/lib/libz.so.tmp) \
$_CARGO_TARGET_LIBDIR/libz.so

LDFLAGS+=" -Wl,--no-as-needed -lpython${TERMUX_PYTHON_VERSION}"

# XXX: Don't know why, this is needed for `cmake` in rust to work properly
local _rtarget _renv
for _rtarget in {aarch64,i686,x86_64}-linux-android armv7-linux-androideabi; do
_renv="CFLAGS_${_rtarget//-/_}"
export $_renv+=" --target=${CCTERMUX_HOST_PLATFORM}"
done
# Dummy CMake toolchain file to workaround build error:
# CMake Error at /home/builder/.termux-build/_cache/cmake-3.30.3/share/cmake-3.30/Modules/Platform/Android-Determine.cmake:218 (message):
# Android: Neither the NDK or a standalone toolchain was found.
export TARGET_CMAKE_TOOLCHAIN_FILE="${TERMUX_PKG_BUILDDIR}/android.toolchain.cmake"
touch "${TERMUX_PKG_BUILDDIR}/android.toolchain.cmake"

cargo vendor
patch --silent -p1 \
-d ./vendor/arboard/ \
< "$TERMUX_PKG_BUILDER_DIR"/arboard-dummy-platform.diff
patch --silent -p1 \
-d ./vendor/jemalloc-sys/ \
< "$TERMUX_PKG_BUILDER_DIR"/jemalloc-sys-0.5.4+5.3.0-patched-src-lib.rs.diff

patch --silent -p1 \
-d "$TERMUX_PKG_SRCDIR" \
< "$TERMUX_PKG_BUILDER_DIR"/patch-root-Cargo.diff

LDFLAGS+=" -Wl,--no-as-needed,-lpython${TERMUX_PYTHON_VERSION},--as-needed"
}

termux_step_make() {
:
}

termux_step_make_install() {
export CARGO_BUILD_TARGET=${CARGO_TARGET_NAME}
export PYO3_CROSS_LIB_DIR=$TERMUX_PREFIX/lib
export PYTHONPATH=$TERMUX_PREFIX/lib/python${TERMUX_PYTHON_VERSION}/site-packages

build-python -m maturin build --release --skip-auditwheel --target $CARGO_BUILD_TARGET

pip install --no-deps ./target/wheels/*.whl --prefix $TERMUX_PREFIX
build-python -m maturin build \
--target $CARGO_BUILD_TARGET \
--release --skip-auditwheel \
--interpreter python${TERMUX_PYTHON_VERSION}

# Fix wheel name, although it it built with tag `cp38-abi3`, but it is linked against `python3.x.so`
# so it will not work on other pythons.
Expand All @@ -116,16 +92,18 @@ termux_step_make_install() {
./target/wheels/polars-$TERMUX_PKG_VERSION-cp$_pyver-cp$_pyver-linux_$TERMUX_ARCH.whl
}

termux_step_post_make_install() {
mv $TERMUX_PREFIX/lib/libz.so.1{.tmp,}
mv $TERMUX_PREFIX/lib/libz.so{.tmp,}
termux_step_make_install() {
pip install --no-deps ./target/wheels/*.whl --prefix $TERMUX_PREFIX
}

termux_step_post_make_install() {
# This is not necessary, and may cause file conflict
rm -f $PYTHONPATH/rust-toolchain.toml

# Remove the vendor sources to save space
rm -rf "$TERMUX_PKG_SRCDIR"/vendor
}

termux_step_post_massage() {
rm -f lib/libz.so.1
rm -f lib/libz.so

tur_build_wheel
}
11 changes: 0 additions & 11 deletions tur-pypi-312/python3.12-polars/cmake-0.1.50-src-lib.rs.diff

This file was deleted.

11 changes: 11 additions & 0 deletions tur-pypi-312/python3.12-polars/patch-root-Cargo.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -134,6 +134,8 @@
# simd-json = { git = "https://github.com/ritchie46/simd-json", branch = "alignment" }
pyo3 = { git = "https://github.com/bschoenmaeckers/pyo3.git", branch = "release-0.23" }
pyo3-ffi = { git = "https://github.com/bschoenmaeckers/pyo3.git", branch = "release-0.23" }
+arboard = { path = "./vendor/arboard" }
+jemalloc-sys = { path = "./vendor/jemalloc-sys" }

[profile.mindebug-dev]
inherits = "dev"