PyO3 / PyO3/pyo3

[BUG] PyO3 0.29 abi3 modules on android linked against `libpython3` fail to load

Open
#6,165 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

Bug Description

Environment

  • PyO3: 0.28 (working), 0.29 (broken)
  • Python: 3.13
  • Platform: aarch64 Linux (Termux/Android)
  • Rust: 1.96.0

Problem

Building a PyO3 extension with abi3-py312 on aarch64 Linux / Python 3.13
produces a .so that references _Py_NoneStruct, which was removed in
Python 3.13:

ImportError: dlopen failed: cannot locate symbol "_Py_NoneStruct"

Confirmed version bisect

  • PyO3 0.28 + abi3-py312 → builds cleanly, imports successfully ✅
  • PyO3 0.29 + abi3-py312 → _Py_NoneStruct linked, crashes on import ❌

Proof

nm -D _core.abi3.so | grep -i none
→ U _Py_NoneStruct

strings _core.abi3.so | grep -i "limited|Py_LIMITED"
→ nothing found

Py_LIMITED_API is not being set during compilation despite abi3-py312
being enabled. PyO3 correctly guards _Py_NoneStruct behind:

#[cfg(all(not(GraalPy), not(all(Py_3_13, Py_LIMITED_API))))]

Without Py_LIMITED_API, that guard is skipped and the removed
symbol gets linked.

Reproduction

Any package using PyO3 0.29 + abi3-py312 built from source on
aarch64 Linux / Python 3.13 will reproduce this. Confirmed via
django-bolt (github.com/dj-bolt/django-bolt):

pip install django-bolt  # builds from sdist on aarch64
python3 -c "import django_bolt._core"
→ ImportError: cannot locate symbol "_Py_NoneStruct"

Downgrading django-bolt to 0.7.6 (which uses PyO3 0.28) fixes it.

Impact

Affects all aarch64 Linux users building PyO3 0.29 extensions
from source, including:

  • AWS Graviton instances
  • Raspberry Pi
  • Any ARM Linux server
  • Termux/Android

Workaround

Downgrade to PyO3 0.28 until fixed.***

Steps to Reproduce

Steps to Reproduce

  1. Use an aarch64 Linux machine (tested on Termux/Android)

  2. Install Python 3.13

  3. Create a virtual environment and activate it

  4. Install any package that uses PyO3 0.29 with abi3-py312
    and builds from source (no prebuilt aarch64 wheel).
    Example using django-bolt:

    pip install django-bolt==0.8.3

  5. Try to import the extension module:

    python3 -c "import django_bolt._core"

Expected Result

Module imports successfully (as it did with PyO3 0.28)

Actual Result

ImportError: dlopen failed: cannot locate symbol "_Py_NoneStruct"

Verification

nm -D _core.abi3.so | grep -i none
→ U _Py_NoneStruct

strings _core.abi3.so | grep -i "Py_LIMITED"
→ nothing (Py_LIMITED_API was never set during build)

Confirmed Bisect

  • django-bolt 0.7.6 (PyO3 0.28) → works ✅
  • django-bolt 0.8.3 (PyO3 0.29) → broken ❌
Backtrace

Your operating system and version

Android 14, aarch64 (Termux)

Your Python version (python --version)

3.13

Your Rust version (rustc --version)

1.96.0

Your PyO3 version

0.29.0

How did you install python? Did you use a virtualenv?

apt install python

yes using python -m venv

Additional Info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the aarch64 Linux/Android build with PyO3 0.29 and abi3-py312, then inspect the build configuration responsible for defining Py_LIMITED_API and compare it with PyO3 0.28. Use nm and strings on the generated extension to verify the unresolved symbol is removed; done means the module imports successfully without referencing _Py_NoneStruct.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, linux, python, rust
Domain
backend, build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.