Repository navigation
Maturin does not work in Python 3.13 on Android unless I edit Maturin #2945
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
using pip install meshage does not work in Python 3.13 on Android because this error occurs:
💥 maturin failed
Caused by: Failed to get information from the python interpreter at /data/data/com.termux/files/usr/bin/python3.13
Caused by: platform.system() in python, android, and the rust target, Target { os: Linux, arch: X86, env: Android, triple: "i686-linux-android", cross_compiling: false, rustc_version: VersionMeta { semver: Version { major: 1, minor: 92, patch: 0 }, commit_hash: Some("ded5c06cf21d2b93bffd5d884aa6e96934ee4234"), commit_date: Some("2025-12-08"), build_date: None, channel: Stable, host: "i686-linux-android", short_version_string: "rustc 1.92.0 (ded5c06cf 2025-12-08) (built from a source tarball)", llvm_version: Some(LlvmVersion { major: 21, minor: 1 }) }, user_specified: false }, don't match ಠ_ಠ
Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/data/data/com.termux/files/usr/tmp/pip-modern-metadata-a3waxdbn', '--interpreter', '/data/data/com.termux/files/usr/bin/python3.13']' returned non-zero exit status 1.
Checking for Rust toolchain....
Running `maturin pep517 write-dist-info --metadata-directory /data/data/com.termux/files/usr/tmp/pip-modern-metadata-a3waxdbn --interpreter /data/data/com.termux/files/usr/bin/python3.13`
However, when I edit Maturin and use several other commands like this, meshage installs successfully in Python 3.13 on Android.
git clone https://github.com/PyO3/maturin.git
cd maturin
git apply -v << 'EOF'
--- a/src/target/mod.rs
+++ b/src/target/mod.rs
@@ -456,6 +456,9 @@ impl Target {
/// Returns the name python uses in `sys.platform` for this os
pub fn get_python_os(&self) -> &str {
+ if (self.is_bionic_libc()) {
+ return "android";
+ }
match self.os {
Os::Windows => "windows",
Os::Linux => "linux",
@@ -682,6 +685,15 @@ impl Target {
)
}
+ /// Returns true if the current platform's target env is Android
+ #[inline]
+ pub fn is_bionic_libc(&self) -> bool {
+ matches!(
+ self.env,
+ Environment::Android
+ )
+ }
+
/// Is cross compiling for this target
#[inline]
pub fn cross_compiling(&self) -> bool {
EOF
pip install .
pip install cffi
export ANDROID_API_LEVEL=24
pip install --upgrade --force-reinstall setuptools
pip cache purge
pip install --no-build-isolation meshageYour maturin version (maturin --version)
maturin 1.11.5
Your Python version (python -V)
Python 3.13.11
Your pip version (pip -V)
pip 25.3 from /data/data/com.termux/files/usr/lib/python3.13/site-packages/pip (python 3.13)
What bindings you're using
cffi
Does cargo build work?
- Yes, it works
If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?
- Yes
Steps to Reproduce
- Install Android
- Install Termux App for Android
- Fully update Termux App (
pkg upgrade) - Install Python 3.13 for Termux App
- Install Rust for Termux App (
pkg install rust) - set the Maturin Android API level to the current minimum API level of Termux App (
export ANDROID_API_LEVEL=24) - Try to install a PyPi package that depends on Maturin (
pip install meshage)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
robertkirkman commentedon Jan 22, 2026
I should note that the patch I sent is not backwards compatible with Maturin in Python 3.12 on Android, so I'm not sure what the best way to fix Maturin for both Python 3.12 on Android and Python 3.13 on Android at the same time would be.
One idea is that I did notice there appears to be a hardcoded loosening/exception in this check for the case of Windows; I don't know if Android could acceptably be granted an exception in the check this way or not.
maturin/src/python_interpreter/mod.rs
Lines 295 to 296 in eaddd6a
messense commentedon Feb 8, 2026
I think we should only aim for Android support for Python 3.14+ given that CPython only added official Android support since 3.14.
mhsmith commentedon Feb 8, 2026
That's not correct, Python added official Android support in 3.13 (https://peps.python.org/pep-0738/).
We didn't start making official binary releases until 3.14, but that isn't an indication of support, since there are no offical binary releases for Linux either.
thunder-coding commentedon Feb 12, 2026
Just gave a better look at maturin, it should be possible to do a proper support for Android while keeping backward compatibility with Python 3.12 and earlier. I'll be opening a PR soon after getting it built locally and testing it. Will be CCing both of you
fix: platform.system() on Android for Python 3.13+
fix: platform.system() on Android for Python 3.13+ (#2992)
DresOperatingSystems commentedon Apr 9, 2026
Temporary Fix — Downgrade to Python 3.11 Until 3.13 Is Stable in Termux
I ran into the same issue and got
maturinworking again by switching to Python 3.11. Here are the steps that worked for me.Steps
1. Install Python 3.11
This installs Python 3.11 alongside your existing 3.13 install, nothing is removed or broken.
2. Remove the broken
getrandomcrate cacheClears a cached Rust crate that has a compatibility issue in Termux. Forcing it out makes Cargo fall back to a working version on the next build.
3. Install maturin under Python 3.11
pip3.11 install "maturin==1.7.4"Installs a version of maturin that is known to work with Python 3.11, avoiding any 3.13 specific binding issues.
4. Symlink Python 3.11 as the default
pythonandpython3Makes
pythonandpython3point to 3.11 without touching or removing your 3.13 install, fully reversible.5. Prioritise
~/binin your PATH and make it permanentThe
exportline alone only lasts for the current session. Writing it to.bashrcmakes it persist across terminal restarts so your symlinks always take priority over system binaries.