Skip to content

feat(python): add support for local Termux/Android builds#750

Open
Manamama-Gemini-Cloud-AI-01 wants to merge 1 commit into
unum-cloud:mainfrom
Manamama-Gemini-Cloud-AI-01:fix/termux-support
Open

feat(python): add support for local Termux/Android builds#750
Manamama-Gemini-Cloud-AI-01 wants to merge 1 commit into
unum-cloud:mainfrom
Manamama-Gemini-Cloud-AI-01:fix/termux-support

Conversation

@Manamama-Gemini-Cloud-AI-01
Copy link
Copy Markdown

This PR implements fixes to enable USearch builds on Termux (Android aarch64) and addresses the linker limitations documented in this issue comment.

🛠️ Summary of Changes

  1. NumKong Bundling: Created python/numkong_bundle.cpp to statically include NumKong source files. This bypasses the Android Bionic linker's restriction on sharing symbols between extensions via RTLD_GLOBAL, which was causing ImportError: cannot locate symbol \"nk_uses_dynamic_dispatch\".
  2. setup.py Refactoring:
    • Added explicit detection for the android platform.
    • Enabled optimized compiler flags (-O3, -ffast-math) for Android.
    • Implemented logic to bundle NumKong sources directly into the USearch extension on Android.
    • Disabled static-libstdc++ on Android to match the Termux environment.
  3. Import Logic: Updated python/usearch/__init__.py to skip the RTLD_GLOBAL loading of the external numkong library on Android, since it's now bundled.
  4. Distribution: Updated MANIFEST.in to include numkong and stringzilla headers/sources, allowing for offline and bundled builds.

✅ Verification

  • Verified successful installation and runtime import on Termux.
  • All 608 tests in python/scripts/test_index.py passed on the device.

- Recognizes 'android' platform in setup.py
- Implements NumKong source bundling for Android to bypass Bionic linker limitations
- Disables static-libstdc++ on Android to match Termux environment
- Skips manual RTLD_GLOBAL load in __init__.py on Android
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.

1 participant