python-native-build
Skill2 starsChanged 57 days agoMITView on GitHub
Diagnose a failed Python install on Termux or Android (compiler or header errors, Rust or maturin builds, no wheel for this platform, glibc wheels that fail at import, externally-managed-environment) and pick the smallest fix, preferring Termux-packaged libraries (the main repo, then tur-repo with consent) over source builds. Use when pip or uv fails, when a build error mentions clang, cc, cargo, rustc or a missing .h file, or when an import fails right after a successful install. Do NOT use for slow downloads, pure-Python packages that install fine, or Node problems (see node-native-build).
- Installs packages
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- background-processesSkill
- git-credentialsSkill
- github-actionsSkill
- node-native-buildSkill
- package-troubleshootingSkill
- proot-boundariesSkill
- storage-permissionsSkill
- termux-adbSkill
- termux-apiSkill
- termux-backupSkill
- termux-environmentSkill
- termux-networkSkill
- termux-servicesSkill
- termux-sshdSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 38
No compatible wheel and no sdist support: say so and offer a substitute or a proot environment.
- Very specific: line 44
Do not use --no-build-isolation until the build requirements are understood.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Native Build
Purpose
Separate a Python packaging problem from a missing Termux toolchain, an unsupported Android wheel, or the wrong environment boundary, then apply the smallest change that fixes it.
When to use
piporuvfails with compiler errors, missing headers, linker errors, Rust build errors, orNo matching distribution.- A package installs but fails on import.
error: externally-managed-environment.
When NOT to use
- Slow installs. Do not add a toolchain because a build is merely slow.
- Failures before pip runs (
pkgerrors): usepackage-troubleshooting. - Node packages: use
node-native-build.
Preconditions
Capture, read-only: python -VV, python -m pip --version, uname -m, the active prefix, whether a venv is active, the exact package and version, and the first meaningful error (not the last line). sh scripts/check-toolchain.sh prints the toolchain facts.
Decision tree
- Classify first. Read
environment_classfrom thetermux-environmenthelper. Onlytermux-nativefollows the Termux steps below.prootand every other class use that system's own package manager and normal PEP 668 rules, with no Termux package names and notur-repo.unknown: ask. - Native Termux install ladder for a Python library. Stop at the first rung that works and do not skip down:
a. The Termux main repository:
pkg search python-<name>. numpy and cryptography live here (python-numpy,python-cryptography), not intur-repo. Install the package withpkg, not pip. b.tur-repo, the community repository: heavier libraries such as scipy and pandas have been distributed there.tur_repoin the helper shows whether it is enabled. Enabling it widens trust: ask, then search again. Placement changes over time, so trustpkg search, not memory. c. A venv with--system-site-packages, so packaged libraries stay visible, then pip for the remaining pure-Python dependencies. If a project pins a version that conflicts with the packaged one, say so and continue at e. d. A third-party wheel index is its own trust decision: ask first. e. Compile from source (steps 6 to 9). externally-managed-environment: Termux marks its Python as externally managed (PEP 668), as other distributions do. Fix in order: a packaged library (rung a or b), else a venv (add--system-site-packagesto keep packaged libraries visible), elsepipx install --system-site-packagesfor command-line apps.--break-system-packagesis a last resort that lets pip overwrite filespkgowns; never the default, and never delete theEXTERNALLY-MANAGEDmarker.failed building wheelfor a library that has a package (rung a or b): do not repair the compile. Install the package; the build error is the symptom of skipping the ladder.- No compatible wheel and no sdist support: say so and offer a substitute or a proot environment. Do not loop on
--no-binary. - Source build: name the missing executable (
clang,make,cmake,pkg-config,rustc,cargo) and the missing header or library separately. Termux headers ship inside the main package (openssl,libffi,libxml2,libjpeg-turbo), not in-devpackages. - Rust or maturin based builds (for example pydantic-core, or cryptography when a project pins a version the package does not match): need
rustandbinutils, and some requireANDROID_API_LEVELset to the device API level (getprop ro.build.version.sdk). Check the project's build error before setting it. - Scientific stacks that fail linking math symbols may need
MATHLIB=min the environment. For numpy the package is the answer: community reports of building it neededMATHLIB=m,LDFLAGS=-lpython3.<minor>, and--no-build-isolationtogether, which is fragile and Python-version specific. Verify against the actual error first. - Installs fine, import fails with
cannot locate symbolor a missinglibc.so.6: a glibc (manylinux) wheel landed on Bionic. Treat as step 5. - Build dies with
Killedor signal 9: lower parallelism (MAKEFLAGS=-j1,CMAKE_BUILD_PARALLEL_LEVEL=1) and seebackground-processes. - Do not use
--no-build-isolationuntil the build requirements are understood; it hides the real dependency boundary.
Failure signatures
| Signature | Layer | Next step |
clang: not found, command 'cc' failed | no compiler | install clang after confirmation |
fatal error: 'x.h' file not found | missing library | find the owning package with pkg search, install it |
unable to find library -lx | missing or wrong library | same as above; check $PREFIX/lib |
can't find Rust compiler or MSRV error | no or old Rust | install or upgrade rust |
No matching distribution found | no wheel for platform | step 2 or 5 |
error: externally-managed-environment | PEP 668 marker | step 3 |
Failed building wheel for numpy, cryptography, scipy, or pandas | packaged library skipped | steps 2 and 4 |
cannot locate symbol at import | glibc wheel on Bionic | step 9 |
Example
- Situation: pip install cryptography fails on a phone with can't find Rust compiler or failed building wheel.
- Without the skill: Installs
rustand retries, or adds--break-system-packagesand--no-build-isolation, compiling a library that Termux already ships. - With the skill: Reads
environment_class: termux-native, findspython-cryptographywithpkg searchin the main Termux repo (not tur-repo), installs that package after confirmation, uses a venv with--system-site-packagesif the project needs one, and verifies withimport cryptographyandpip check.
Safety
Installing packages, creating venvs, and exporting build flags change the environment: state the exact change and confirm. Third-party package repositories (for example tur-repo) and third-party wheel indexes widen the trust boundary; ask before adding one.
Verification
Re-run the original install, then python -c "import <module>" and python -m pip check. Report what remains unsupported on Android.
Rollback
Record every package and venv created for this attempt. Remove only those, and never delete a user environment without explicit approval.
Handoffs
termux-environmentwhen architecture, Python, or toolchain facts are missing.package-troubleshootingwhenpkgitself fails.proot-boundarieswhen the package needs glibc.background-processeswhen the build is killed.node-native-buildwhen the failing package is a Node module.
Report
Root cause in one line (layer plus first real error), the single change applied, the verification result, and any limit that remains.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

