Skip to content

Fix: the Android AAR keeps every stdlib directory starting with _ (#546) - #547

Merged
b-re-w merged 1 commit into
developfrom
feat/aar-underscore-assets
Nov 27, 2026
Merged

b-re-w merged 1 commit into
developfrom
feat/aar-underscore-assets

Conversation

@b-re-w

@b-re-w b-re-w commented Nov 27, 2026

Copy link
Copy Markdown
Member

Closes #546

AGP's default ignoreAssetsPattern contains <dir>_*, so the AAR dropped every stdlib directory starting with _ (zipfile/_path, _pyrepl, __phello__, compression/_common, ensurepip/_bundled, ...). importlib.metadata needs zipfile._path, so torchnative's app failed on the Flip4 with "No module named 'zipfile._path'".

  • Defect fixed: android { androidResources { ignoreAssetsPattern = ... } } is AGP's default without <dir>_*.
  • Test added:
    • verifyAarStdlib (Gradle, verification): every file copyAndroidPythonAssets stages must be in the release AAR. Red before the fix: "the AAR lacks 110 of 1784 staged asset files (Android AAR drops every stdlib directory starting with _ (AGP ignoreAssetsPattern) #546)", first entries __phello__/__init__.py, _pyrepl/__init__.py. Green after: "all 1784 staged asset files are in the AAR".
    • AndroidStdlibAssetsTest (instrumented): find_spec for zipfile._path, _pyrepl, compression._common, __phello__, and importlib.metadata imports. Compiled locally (compileDebugAndroidTestKotlinAndroid); it runs on the CI emulator.
  • CI: the emulator job's build step also runs :python-multiplatform:verifyAarStdlib (no new workflow or job).

An app that merges this AAR still applies its own pattern; that side is toolchain #166.

…P's <dir>_* asset filter dropped 110 files, including zipfile/_path)

verifyAarStdlib compares the staged asset tree with the release AAR; red before the fix
(110 of 1784 files missing), green after. AndroidStdlibAssetsTest checks zipfile._path,
_pyrepl, compression._common, __phello__ and importlib.metadata on the device. #546
@b-re-w
b-re-w merged commit 950ef04 into develop Nov 27, 2026
@b-re-w
b-re-w deleted the feat/aar-underscore-assets branch November 27, 2026 05:27
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