feat(android): add Rust cross-compilation setup for Android environment#2650
Conversation
|
For Rust projects built with Maturin, it currently does not work. Maturin has some cross-compilation issues on Android that still need to be fixed. For details, please see PyO3/maturin#2810 |
|
This looks nice and neat! Is there an example of it working in a real project that you've been testing it with? |
|
I want to test, but I did not know how to run this without the github action,if you know how to do, you can tell me,and I will test it. This commit is a modification I made based on the actual missing environment configuration built on Android using cbuildwheel. Of course, I manually configured it externally in a non-isolated environment, and after the configuration, I built the wheel correctly and it can run on Android |
|
You can test a project using something like this in a github workflow- - name: Build wheels
uses: ririv/cibuildwheel@main |
1384753 to
99ee18a
Compare
…_DIR to link against libpython3.x.so explicitly
|
Thanks, I have tested it, and made some new commits. Now, it works.
The
|
|
https://github.com/ririv/android-wheels/blob/main/.github/workflows/cbuildweel-repair-test.yml Here are some logs:
|
|
Looks good to me! @mhsmith what do you think? |
|
Sorry for the delay, I'll look at this as soon as I can. |
There was a problem hiding this comment.
Pull request overview
This pull request adds Rust cross-compilation setup for the Android platform, mirroring similar functionality that exists for Windows. The implementation configures environment variables necessary for building Rust-based Python packages (using setuptools-rust and PyO3) when cross-compiling for Android targets.
Key Changes:
- Added
setup_rust_cross_compile()function to configure Cargo build target and linker environment variables - Added
setup_PYO3_cross_compile()function to set PyO3 cross-compilation library directory - Integrated both functions into the Android environment setup process
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… cargo and rustup
for more information, see https://pre-commit.ci
|
Thanks for the suggestions. I've updated the PR to address the feedback:
|
|
Since PyO3/maturin#2825 has been merged into main, we can now use cibuildwheel to test Rust projects built with maturin. However, as a new version hasn't been released yet, we have to build maturin from source for now. This is the GItHub Action script: This is the logs:
Sorry, there are still some issues with the maturin integration: it's building for Linux instead of Android. This might be a problem with the
However, we can still use a conversion tool to transform maturin projects into setuptools-rust projects and successfully build Android wheels.
|
|
I have investigated the issue with the wheel generated by maturin. It actually produced the correct wheel, but the tag was incorrect. This issue is unrelated to the current PR. So, no modification is necessary. |
|
Thanks; I'm on vacation at the moment, but I'll look at this in the new year. |
|
Key Changes:
Ready for re-review. Thanks! @mhsmith |
|
Here is how the Rust shim script integrates into the build process:
|
mhsmith
left a comment
There was a problem hiding this comment.
Thanks, everything looks good now.
joerick
left a comment
There was a problem hiding this comment.
Thanks both for your work on this. Looks good to me.
Like platform
windowscibuildwheel/cibuildwheel/platforms/windows.py
Lines 206 to 232 in c53e541
Add Rust cross-compilation setup for Android environment, it can fix the cross-compilation problem for the rust project built with setuptools-rust