Skip to content

fix(android): bundle every ABI's _sysconfigdata into the ABI-common stdlib.zip#218

Open
FeodorFitsner wants to merge 2 commits into
mainfrom
fix/android-x86_64-sysconfigdata
Open

fix(android): bundle every ABI's _sysconfigdata into the ABI-common stdlib.zip#218
FeodorFitsner wants to merge 2 commits into
mainfrom
fix/android-x86_64-sysconfigdata

Conversation

@FeodorFitsner

Copy link
Copy Markdown
Contributor

Problem

The pure stdlib.zip is ABI-common and built once from the primary ABI (abis.first(), e.g. arm64-v8a). But _sysconfigdata__<arch> is arch-specific: each ABI ships its own (e.g. _sysconfigdata__android_x86_64-linux-android), and CPython imports the one matching the running device at startup (sysconfig._init_posix, pulled in by ctypes).

So on a non-primary ABI (e.g. an x86_64 emulator when arm64-v8a is primary) the embedded interpreter crashes on startup:

ModuleNotFoundError: No module named '_sysconfigdata__android_x86_64-linux-android'

This was caught by Flet's new on-device flet test CI running on an x86_64 Android emulator (passes on arm64 devices/emulators, where the primary ABI's sysconfigdata happens to match).

Fix

The primary splitStdlib task now also harvests every other ABI's stdlib/_sysconfigdata* from its libpythonbundle.so into stdlib.zip — depending on the other ABIs' untar so their bundles exist to read, and holding non-primary tasks until the primary has read them (each task deletes its own bundle at the end).

Validation

A patched APK build's stdlib.zip now contains both _sysconfigdata__android_aarch64-linux-android.pyc and _sysconfigdata__android_x86_64-linux-android.pyc (previously only the aarch64 one).

…tdlib.zip

The pure stdlib.zip is built once from the primary ABI (abis.first(), e.g.
arm64-v8a), but _sysconfigdata__<arch> is arch-specific: each ABI ships its own
(e.g. _sysconfigdata__android_x86_64-linux-android) and CPython imports the one
matching the running device at startup (sysconfig, pulled in by ctypes). So on
a non-primary ABI (e.g. an x86_64 emulator) the embedded interpreter crashed
with 'ModuleNotFoundError: No module named _sysconfigdata__android_x86_64-linux-android'.

The primary splitStdlib task now also harvests every other ABI's
stdlib/_sysconfigdata* from its libpythonbundle.so into stdlib.zip (depending on
the other ABIs' untar and holding non-primary tasks until the primary has read
their bundles).
FeodorFitsner added a commit to flet-dev/flet that referenced this pull request Jun 26, 2026
…anch

Temporarily override serious_python_android + serious_python_platform_interface
to flet-dev/serious-python#218 (fix/android-x86_64-sysconfigdata) so the android
x86_64 CI leg validates the fix end-to-end (embedded Python no longer crashes
with ModuleNotFoundError: _sysconfigdata__android_x86_64-linux-android).

Locally confirmed: pubspec.lock resolves to the branch and stdlib.zip now ships
both aarch64 and x86_64 _sysconfigdata. Revert to the pub.dev release once #218
ships.
…id dup)

The previous harvest matched stdlib/_sysconfigdata*, which also catches the
generic, ABI-identical _sysconfigdata__linux_ that some Python versions (e.g.
3.12) ship in every ABI. The primary ABI already adds that via the stdlib loop,
so re-adding it from a non-primary ABI threw 'java.util.zip.ZipException:
duplicate entry: _sysconfigdata__linux_.pyc'. Match only the per-ABI
_sysconfigdata__android_<arch> modules (unique per ABI), which is exactly what
CPython imports on-device. Add CHANGELOG entry (4.1.1).
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