Cibuildwheel: Alpine Linux Support

Created on 25 Nov 2020  路  7Comments  路  Source: joerick/cibuildwheel

Given the rise in Popularity of Docker, lightweight alpine Images are more freuently being used and it would be cool to be able to output wheels for alpine.

Give Pypa doens't support them they can be an optional feature, but should exist so wheels can still be built and uploaded to things like github registery.

Maybe an Optional env var like BUILD_ALPINE

Most helpful comment

No, what I meant was to build a docker image that was close enough to manylinux in structure that we could plug it into the CIBW_MANYLINUX* option and run it instead of a real manylinux image. But it would try to run auditwheel, so you'd likely need to mock that or it wouldn't work.

All 7 comments

It would actually be more useful to have something like CIBW_NATIVE_LINUX that would build in the current image/docker container instead of running docker (it might also help with running alternate arches on GHA, for example). But it likely would be a very large change - you'd probably have a new nativelinux.py, I'd expect, as not running everything in docker is a big change.

I wonder if you could provide a manylinux-like docker image that used Alpine instead, though? (just to solve this problem, not the GHA + ARM one)

I'm afraid thats not possible. The reason the issue occurs is manylinux based distro's use glibc whereas alpine uses musl. That makes alpine not many linux compatible. Wheel's for alpine can't be uploaded to pypi.

Thats why the existing manylinux is alpine incompatible.

No, what I meant was to build a docker image that was close enough to manylinux in structure that we could plug it into the CIBW_MANYLINUX* option and run it instead of a real manylinux image. But it would try to run auditwheel, so you'd likely need to mock that or it wouldn't work.

But it would try to run auditwheel, so you'd likely need to mock that or it wouldn't work.

CIBW_REPAIR_COMMAND="" would disable that I think

At the risk of sounding rude (not meaning to, though): what's the problem with setting up a job that runs on Alpine, independent of cibuildwheel? I believe/think cibuildwheel's goal is to set up the whole environment correctly to produce wheels that can be uploaded to PyPI.
But since that's not the case here, you could just write a loop over the Python versions in an Alpine image, and call pip wheel .?

I see alpine linux in many places, but I think that first issue should be put in warehouse repository or even some proposition of PEP for alpine linux suffix for wheel.

Then proper changes need to be done in pip to check if running un musl or glibc system and then select proper wheel. Then adding a building wheel in a tool like cibuildwheel is worth it.

If you would like to stop building wheels in your own CI pipeline You could build a set of wheels using pip wheel and copy a set of prepared wheels.

Looking on growing popularity of alpine I think it is worth.

So, to clarify the above, it should be possible to build alpine wheels by setting CIBW_REPAIR_COMMAND="" and creating Alpine Docker image in the style of https://github.com/pypa/manylinux, and then selecting them using CIBW_MANYLINUX_X86_64_IMAGE.

The docker images would need Python installations at these locations. Perhaps these could just be symlinks to package-installed Pythons. You could also skip lots of those and only build the ones you care about using CIBW_BUILD.

I don't think there's anything for cibuildwheel to do to support this further, but keep us posted on your progress!

Was this page helpful?
0 / 5 - 0 ratings