eclipse-zenoh/zenoh-python

Binary wheels for armv6

JEnoch opened this issue ยท 10 comments

Describe the feature

zenoh-python relies on pypa/cibuildwheel to build the binary wheels that are released on pypi.org.
However it doesn't support armv6 and armv7 architectures. The reason being there is no manylinux image available for armv6 nor armv7.

EDIT 2022-06-08:
Thanks to #66 an armv7 wheel is now built. The build now relies on messense/maturin-action which doesn't provide a solution for armv6.

For Raspberry Pi, an alternative could have been to rely on the piwheels project. Unfortunately its infrastructure relies on Debian's Rust which is 1.48 and is too old to build some of the zenoh dependencies (see piwheels/packages#263)

The ideal solution would be to create a custom manylinux image for armv6 and armv7.
But that looks challenging looking at the long standing discussion in pypa/manylinux#84.

Another solution suggested on zenoh Discord by CircleOWO:

We once built the zenoh rust on RPi by cross-compiling with the toolchain armv7-unknown-linux-musleabihf.
I can confirm PyO3 can build up zenoh-python in wheel package for ARMv7 through musl, but the problem is python wheel doesn't support musl on RPi. So even you can build it, you can't install it in on your RPi.
So there's another solution for the cross-compiling, you need to build zenoh-python by the tool chain armv7-unknown-linux-gnueabihf and try to pack it to a manylinux wheel. But this comes with other difficulties since the glibc version on your RPi may be mismatched with your host machine, which may take some time to resolve it.

Hi, @JEnoch, I proposed a PR #66 to resolve this issue. It is a breaking change in the workflows of CI/Release. Any comments are welcome.
BTW, I had checked the building parts in CI and release. But haven't checked the publishment since I don't have permission. So this part may need your help. Thanks!

Thanks @YuanYuYuan ! I tested your solution and it works well (see results here: https://pypi.org/project/eclipse-zenoh-nightly/0.6.0.dev20220608/#files). The armv7 wheel works at least in a arm32v7/ubuntu Docker container.

So I merged you PR, and Github automatically closed this ticket (as the commit includes "resolve #64").
I re-open and update this ticket for the armv6 case that still needs a solution, since messense/maturin-action doesn't yet provide an armv6 Docker container.

Thanks.

I've added linux armv6l support in PyO3/maturin#966, although we don't have a docker image for maturin-action, I do have a arm-unknown-linux-gnueabihf cross compiler for macOS in https://github.com/messense/homebrew-macos-cross-toolchains that you can try on macos-latest GitHub Actions runners.

brew tap messense/macos-cross-toolchains
brew install arm-unknown-linux-gnueabihf

export CC_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-gcc
export CXX_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-g++
export AR_arm_unknown_linux_gnueabihf=arm-unknown-linux-gnueabihf-ar
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-unknown-linux-gnueabihf-gcc

pip3 install maturin
maturin build --release --target arm-unknown-linux-gnueabihf --out dist

@messense, thanks for your great help!

From our experience, cross-compiling through gnueabihf has the potential glibc version mismatch between the host and the target. @JEnoch can we figure out the glibc version used in supported armv6l platforms?

I think all armv6 use cases we saw were "old" Raspberry Pis such as RPi Zero W or RPi 1-B.
The oldest Raspberry OS was based on Debian Wheezy that uses glibc 2.13.
But then (in 2015) Jessie-based Raspberry OS came with glibc 2.19.

So I think supporting glibc 2.17 is very fine since for the vast majority of those old hardware their users already moved (or are able to move) to Jessie or even more recent Raspberry OS.

Thanks @messense for your great support! We'll try your cross toolchain on GitHub Actions ASAP.

I confirm that the wheel built with arm-unknown-linux-gnueabihf cross-compiler works well on Raspberry Pi Zero W (ARMv6Z) with latest Raspberry Pi OS (glibc 2.31). ๐ŸŽ‰
PR coming...