Skip to content

tur-packages/python-orjson: add version 3.10.18#2308

Open
shaheen-coder wants to merge 2 commits into
termux-user-repository:masterfrom
shaheen-coder:add-python-orjson
Open

tur-packages/python-orjson: add version 3.10.18#2308
shaheen-coder wants to merge 2 commits into
termux-user-repository:masterfrom
shaheen-coder:add-python-orjson

Conversation

@shaheen-coder

Copy link
Copy Markdown

packages/python-orjson: add version 3.10.18

What is this?

Adding python-orjson — a fast JSON library for Python built with Rust and PyO3.

Why orjson?

Anyone doing serious data work in Termux hits the same wall — Python's built-in json module is slow. orjson fixes that. It serializes common types like datetime, numpy arrays, dataclasses and UUID out of the box with no extra code, and it's consistently the fastest JSON library available for Python.

For Termux users running data pipelines, scraping scripts, or API tools on their phone — this matters.

Build notes

This was not a straightforward package to build. orjson uses maturin as its build backend (Rust + PyO3), which required careful cross-compilation setup for Android:

  • Cross-compiled with maturin targeting aarch64-linux-android (API level 24)
  • PYO3_CROSS environment used to point maturin at the Termux cross Python headers
  • Rust toolchain set up via termux_setup_rust + rustup target add
  • Wheel extracted directly into $TERMUX_PREFIX since host pip cannot install cp313 wheels

Tested on

Architecture Status
aarch64

Note to reviewers

This is my first contribution to TUR. I spent considerable time figuring out the maturin cross-compilation setup for Android — happy to refine anything in the build.sh based on your feedback. If there are conventions I missed, please let me know and I'll fix them promptly.

Comment thread tur-packages/python-orjson/build.sh
Comment thread tur-packages/python-orjson/build.sh
Comment thread tur-packages/python-orjson/build.sh
termux_step_make_install() {
WHEEL=$(find "$TERMUX_PKG_BUILDDIR/wheels" -name "orjson-*.whl" | head -1)
echo "Installing wheel: $WHEEL"
unzip -o "$WHEEL" -d "$TERMUX_PREFIX/lib/python3.13/site-packages/"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .whl file should be installed using the pip install --force-reinstall --no-deps --prefix="$TERMUX_PREFIX" "$_whl" command where $_whl contains the path to the .whl file

"$MATURIN_BIN" build \
--release \
--target aarch64-linux-android \
--strip \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--strip is not necessary to specify since termux_step_strip_elf_symbols() will do that afterward automatically


PYO3_CROSS=1 \
PYO3_CROSS_LIB_DIR="$TERMUX_PREFIX/lib" \
PYO3_CROSS_PYTHON_VERSION="3.13" \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be $TERMUX_PYTHON_VERSION rather than hardcoded 3.13


termux_step_make() {
termux_setup_rust
rustup target add aarch64-linux-android

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not necessary - termux_setup_rust should be sufficient

TERMUX_PKG_DESCRIPTION="Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy"
TERMUX_PKG_LICENSE="Apache-2.0, MIT"
TERMUX_PKG_MAINTAINER="Shaheen <shaheenvsa@gmail.com>"
TERMUX_PKG_VERSION=3.10.18

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try TERMUX_PKG_VERSION="3.11.7" instead

TERMUX_PKG_LICENSE="Apache-2.0, MIT"
TERMUX_PKG_MAINTAINER="Shaheen <shaheenvsa@gmail.com>"
TERMUX_PKG_VERSION=3.10.18
TERMUX_PKG_SRCURL=https://files.pythonhosted.org/packages/source/o/orjson/orjson-3.10.18.tar.gz

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try using this TERMUX_PKG_SRCURL instead:

TERMUX_PKG_SRCURL="https://github.com/ijl/orjson/archive/refs/tags/$TERMUX_PKG_VERSION.tar.gz"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants