Skip to content

CI Build musllinux wheels #28490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Conversation

kvanzuijlen
Copy link

Reference Issues/PRs

Fixes #27004

What does this implement/fix? Explain your changes.

I've added a wheel-output for musllinux, for faster installation on (among others) Alpine-Linux.

Any other comments?

Since Alpine-Linux is used increasingly, pre-building wheels for Alpine-Linux is a must-have IMO.

I'm unfamiliar with the codebase, so I might've missed something. I tried my best to test it locally by running CIBW_PROJECT_REQUIRES_PYTHON=">=3.12" CIBW_BUILD=cp312-musllinux_x86_64 cibuildwheel --platform=linux --output-dir wheelhouse --archs x86_64 on my M2 ARM MacBook.

Copy link

github-actions bot commented Feb 20, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: fbca77a. Link to the linter CI: here

@lesteve
Copy link
Member

lesteve commented Feb 21, 2024

I tried my best to test it locally by running CIBW_PROJECT_REQUIRES_PYTHON=">=3.12" CIBW_BUILD=cp312-musllinux_x86_64 cibuildwheel --platform=linux --output-dir wheelhouse --archs x86_64 on my M2 ARM MacBook.

Have you tried using the produced wheel in an alpine container? I am a bit surprised that this would "just work", but maybe cibuildwheel does some clever magic ...

For now, I am going to reopen the associated issue and trigger a wheel build to see what happens in this PR.

@kvanzuijlen
Copy link
Author

Have you tried using the produced wheel in an alpine container? I am a bit surprised that this would "just work", but maybe cibuildwheel does some clever magic ...

Not yet, but will try! As far as I could see, cibuildwheel is meant for exactly this, but I'm not familiar with the project/cibuildwheel, so I could be mistaken.

@kvanzuijlen
Copy link
Author

@lesteve I tried the following:

CIBW_PROJECT_REQUIRES_PYTHON=">=3.12" CIBW_BUILD=cp312-musllinux_x86_64 cibuildwheel --platform=linux --output-dir wheelhouse --archs x86_64

cd wheelhouse

docker run --platform linux/amd64 -i -t -v ./scikit_learn-1.5.dev0-cp312-cp312-musllinux_1_1_x86_64.whl:/scikit_learn-1.5.dev0-cp312-cp312-musllinux_1_1_x86_64.whl python:3.12-alpine /bin/ash

# ---------------- IN DOCKER CONTAINER ------------- #
pip install scikit_learn-1.5.dev0-cp312-cp312-musllinux_1_1_x86_64.whl
# installed successfully

python
# ------------- IN PYTHON CONSOLE ------------ #
>>> import sklearn
>>> dir(sklearn)
['_BUILT_WITH_MESON', '__SKLEARN_SETUP__', '__all__', '__builtins__', '__cached__', '__check_build', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_config', '_distributor_init', 'base', 'clone', 'config_context', 'exceptions', 'externals', 'get_config', 'logger', 'logging', 'os', 'random', 'set_config', 'setup_module', 'show_versions', 'sys', 'utils']

Looks like it works as far as I can tell.

@lesteve
Copy link
Member

lesteve commented Feb 21, 2024

Indeed, it looks like cibuildwheel detects that scikit-learn can be built with Meson, which I thought was indeed a prerequisite to allow cross-compilation. Meson support was added once month ago or so in #28040.

That would be great if you could try running the scikit-learn tests in your container, something like pytest --pyargs sklearn and check that there are no failures 🙏. If there are failures, please post the full output including stack-traces so we can have an idea how much work needs to be done to get the tests to pass on musllinux.

Something more that can be fixed later, there seems to be an issue with the changes in this PR. From one of the muslinux build log it looks like the wheel created is not a musllinux one (no musllinux in the wheel name):

Created wheel for scikit-learn: filename=scikit_learn-1.5.dev0-cp310-cp310-linux_x86_64.whl

@kvanzuijlen
Copy link
Author

kvanzuijlen commented Feb 21, 2024

That would be great if you could try running the scikit-learn tests in your container, something like pytest --pyargs sklearn and check that there are no failures 🙏. If there are failures, please post the full output including stack-traces so we can have an idea how much work needs to be done to get the tests to pass on musllinux.

Running it now, will add a comment once it's finished. (currently at 25% and no unexpected fails (other than xfail) yet)

Something more that can be fixed later, there seems to be an issue with the changes in this PR. From one of the muslinux build log it looks like the wheel created is not a musllinux one (no musllinux in the wheel name):

Created wheel for scikit-learn: filename=scikit_learn-1.5.dev0-cp310-cp310-linux_x86_64.whl

I think that's not the final product of the build step right? At the end of the build step, the following gets logged:

  scikit_learn-1.5.dev0-cp310-cp310-musllinux_1_1_x86_64.whl   13,097 kB

@kvanzuijlen
Copy link
Author

Tests have run successfully:

28913 passed, 3788 skipped, 88 xfailed, 45 xpassed, 4955 warnings in 771.18s (0:12:51)

@lesteve
Copy link
Member

lesteve commented Feb 21, 2024

OK great if the test pass locally. I think you are right that a musllinux wheel is produced in the end. Looking closer it also looks the tests are running and they pass.

So I guess it is up to us (scikit-learn maintainers) to decide whether we want to have scikit-learn wheels on PyPI.

In the mean-time, as I noted in #27004 (comment), there seems to be community-maintained wheels for musllinux. Quickly testing it seems like the command below works inside an Alpine container:

pip install --extra-index https://alpine-wheels.github.io/index/-/simple/ scikit-learn --only-binary :all:

@kvanzuijlen
Copy link
Author

@lesteve Anything you expect from me except for being patient? Let me know if there's anything I can/should do!

@lesteve
Copy link
Member

lesteve commented Feb 21, 2024

@lesteve Anything you expect from me except for being patient? Let me know if there's anything I can/should do!

There is nothing else to do on your side, this PR and your local tests were already quite useful, thanks for this!

@lesteve lesteve changed the title ci: Build musllinux wheels CI Build musllinux wheels Feb 21, 2024
@betatim
Copy link
Member

betatim commented Feb 21, 2024

Looking at this, I'd vote for providing the wheels. What are the downsides? More wheels being built, so more chances for something to go wrong? It might not be easy to stop providing them again? Are there hidden assumptions in scikit-learn's code regarding glibc (is that even a thing that is possible?)?

If Numpy and Scipy have been building wheels for a while I'd assume the process is pretty mature.

@kvanzuijlen
Copy link
Author

I'm also working on musl wheels for another library, and tbh the process doesn't feel really mature within their pipeline setup, but that could also be (my unfamiliarity with) their pipeline setup.

Since numpy, scipy, pandas, and Google Cloud (a.o.) provide musllinux packages I think its the latter.

@lesteve
Copy link
Member

lesteve commented Feb 21, 2024

@betatim I replied in the associated issue #27004 (comment), since I feel this is more suited to the discussion "do we want musllinux wheels or not".

@lesteve
Copy link
Member

lesteve commented Mar 4, 2024

Closing this as not planned for now, see #27004 (comment) for more details.

We can always reopen this PR if the consensus on musllinux wheels changes.

@lesteve lesteve closed this Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upload musllinux wheel to PyPI
3 participants