Skip to content

Add Android support#643

Open
mhsmith wants to merge 34 commits intopypa:mainfrom
mhsmith:android
Open

Add Android support#643
mhsmith wants to merge 34 commits intopypa:mainfrom
mhsmith:android

Conversation

@mhsmith
Copy link
Copy Markdown
Member

@mhsmith mhsmith commented Dec 13, 2025

This will be used by cibuildwheel to replace its limited built-in support for adding external libraries to an Android wheel.

This involves cross-compilation, but it doesn't have much of an overlap with #512. It adds the --ldpaths option, which allows auditwheel to search an arbitrary sysroot, rather than the build machine's own libraries.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.76%. Comparing base (e21df8b) to head (c12866f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #643      +/-   ##
==========================================
+ Coverage   95.34%   95.76%   +0.41%     
==========================================
  Files          22       23       +1     
  Lines        1870     1935      +65     
  Branches      355      367      +12     
==========================================
+ Hits         1783     1853      +70     
+ Misses         48       46       -2     
+ Partials       39       36       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mhsmith
Copy link
Copy Markdown
Member Author

mhsmith commented Mar 31, 2026

Yes, in fact my desktop machine uses macOS, so I used it for almost all of my testing. I guess this means we should add a CI job for that platform as well, but I'll wait for your review before I deal with that.

Comment thread src/auditwheel/policy/android-policy.json
Comment thread src/auditwheel/elfutils.py Outdated
Comment thread src/auditwheel/patcher.py Outdated
Comment thread src/auditwheel/patcher.py Outdated
Comment thread src/auditwheel/lddtree.py Outdated
@mayeut mayeut requested a review from lkollar April 12, 2026 09:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends auditwheel to support auditing/repairing Android wheels (PEP 738) in cross-compilation scenarios, primarily by allowing library discovery via an explicit sysroot search path rather than the build machine’s default linker paths.

Changes:

  • Add Android as a supported libc/policy target (new android-policy.json, Android-aware WheelPolicies behavior).
  • Introduce --ldpaths to control external library search paths (used by show, repair, and lddtree).
  • Update grafting/patching behavior to better support Android RUNPATH semantics; add unit + integration tests and Android fixture wheels/libs.

Reviewed changes

Copilot reviewed 26 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/auditwheel/libc.py Adds Libc.ANDROID and a tag_prefix mapping for platform tag detection.
src/auditwheel/policy/__init__.py Loads Android policy JSON and selects appropriate policy based on wheel API level tag; Android-specific external ref filtering.
src/auditwheel/policy/android-policy.json Defines Android library whitelists for selected API levels.
src/auditwheel/options.py Centralizes shared CLI options; adds --ldpaths.
src/auditwheel/lddtree.py Adds --ldpaths parsing/handling and improves $ORIGIN expansion rules.
src/auditwheel/wheel_abi.py Plumbs --ldpaths into ELF analysis and ensures Android analysis doesn’t implicitly use host linker paths.
src/auditwheel/main_show.py / src/auditwheel/main_repair.py / src/auditwheel/main_lddtree.py Wires --ldpaths into subcommands; adjusts repair flow for new patcher behavior.
src/auditwheel/patcher.py Makes patchelf behavior platform-aware (Android RUNPATH handling + API-level restriction).
src/auditwheel/repair.py Sets $ORIGIN rpath/runpath on grafted libraries unconditionally.
src/auditwheel/wheeltools.py Adds helpers for platform tag extraction and Android API parsing; updates libc/arch detection accordingly.
src/auditwheel/architecture.py Adds arm64_v8a and normalizes to baseline aarch64.
src/auditwheel/elfutils.py Adds SONAME reader helper.
Tests (tests/unit/*, tests/integration/*) Adds Android coverage, --ldpaths coverage, and fixtures for Android wheel repair behavior.
README.rst Updates messaging to include Android wheels and notes macOS as a potential host for Android wheel work.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/auditwheel/repair.py Outdated
Comment thread src/auditwheel/main_repair.py
Comment thread src/auditwheel/main_repair.py
Copy link
Copy Markdown
Member

@mayeut mayeut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple questions/suggestions remain
I think we're almost there, thanks.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 31 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/auditwheel/options.py Outdated
Copy link
Copy Markdown
Member

@mayeut mayeut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

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.

4 participants