-
Notifications
You must be signed in to change notification settings - Fork 424
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
Test python manylinux package #752
Comments
This approach seems to break build on ubuntu 20.04: https://github.com/google/magika/actions/runs/11274566487/job/31353998130#step:5:1898 |
The actual requirement seems to be glibc >= 2.35 (ubuntu 22.04), see pykeio/ort#293. |
Can we link against an old version of ort crate so that we don't need such a high version of glibc? |
That could be an option, but that would mean:
|
Ok, good points, linking against old crate could result in even more headaches. Let's put this plan aside for the moment. Thought about two other things:
Thoughts? /cc @invernizzi |
I think we can follow the proper route of compiling rust binaries that are manylinux compatible, likely using https://github.com/rust-cross/manylinux-cross This blog post can be our starting point: https://medium.com/@urschrei/building-manylinux-compatible-rust-binaries-for-use-in-python-wheels-d5d943619af2 (it's a bit old, so likely needs some updates) I'll try to set up a minimal project to do that, and we can see what's possible |
Also, https://github.com/pypa/auditwheel seems very useful |
@invernizzi my understanding from @ia0 is that we can't do that due to problems with the ort crate, which we depend on. To my understanding, ort crate has dependencies on a too-high version of glibc, which is too high for the currently available manylinux options. BTW, as of now I don't think we have any way to have a magika rust binary that works on ubuntu 20.04 (which is still supported until next year), so this seems a problem bigger than the mere python packaging. |
Understood. I put together a repo anyway to test this, as it can be useful once Here it is. The guide on how to run it is on that repo. Salient bits:
After that, it can be installed in Ubuntu 20.04 (see the README.md in that repo). Salient bits: Processing /workspace/rust/hello/target/wheels/hello-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Installing collected packages: hello
Successfully installed hello-0.1.0
Testing Python import
Hello from hello!
Running the executable
Hello, world!
Dropping into an interpreter
root@2913ecd93d74:/# It seems it's working out fine |
The issue might only present itself when ort is actually used - I haven't tested that. I'll leave it to the great @ia0 to tell me what it is I'm not seeing here |
The difference is probably that you need to add the |
@invernizzi nice!
@ia0 I see... but is there any big challenge in compiling from source then? And it makes sense that the issue is with built-in binaries... I would expect it to be relatively rare to truly use glibc features that are so cutting edge... |
I don't know, it just needs to be done, and confirm that there are no other problems on that new step. |
@invernizzi, interesting; this looks very promising. For context, we detected the problems when we tried to create the python package on a ubuntu 20.04 machine: something related to ort complains about "undefined reference to symbol XYZ in glibc"... which makes sense, as it seems some prebuilt binaries rely on a newer version of glibc. The difference from your setup seems to be: you built the package on a recent ubuntu, and then you tried to install and run on a 20.04 machine... which could work for us! The concern I have is: are we sure it would actually work? It seems that for now we are relaying on prebuilt binaries... that apparently rely on symbols not present in old glibc... can it be that we don't see problems because this setup relies on lazy loading of the dynamically linked dependencies? Maybe we could try to run the binary with
ACK. So, it could really be that ort per-se doesn't truly rely on newer glibc, and it could be this problem goes away. I think this is the most reasonable next step. @ia0 please go for it when you have some time and let us know whether there are unexpected challenges! Thank you! |
Ok so I probably have something working (still need to wait some confirmation/cleanup workflow runs). Apparently, the v2 of There are linking problems when using the latest In #747 I have an example workflow building a wheel for linux I'm still running 2 experiments in that PR:
|
This looks like good news! Approved #760. I've seen you are playing with a maturin workflow; I guess the plan would be that, once all is fixed, we could just integrate whatever you came up with within the build package workflow (which currently lives in https://github.com/google/magika/blob/main/.github/workflows/python-build-and-upload-packages.yml and relies on https://github.com/google/magika/blob/main/python/scripts/build_python_package.py)? |
I'm not sure how well we'll be able to integrate with the existing workflow. The 2 difficult points are:
The alternative is to just use Maturin and run the version swap logic there. Unless there is something else custom that we need to do? I just checked the Maturin output and it seems to be correct (including the version even though I didn't swap anything, so maybe it's now fixed in Maturin). Steps to reproduce:
|
This is what we currently do in the build package script (https://github.com/google/magika/blob/main/python/scripts/build_python_package.py):
For the looks of it, most of the complexity should go away if we can have a legit manylinux package from maturin, so, using maturin workflow (and get rid of the existing build script) seems very doable? The catch: in the current build gh workflow, we actually do a bit more than building: we build it, then I try to install it, and I've run some tests. But again, it looks like we could do all this within the maturin workflow you are working on. I propose: let's finish whatever last tests you are doing, then we discuss how to proceed. But both options seem reasonable, I don't see anything blocking here. Having an actual legit manylinux package would be really good news! |
In this workflow, you can get all the wheels generated by Maturin: https://github.com/google/magika/actions/runs/11437454207. (Note that the cache reduces the runtime from 40 minutes to 2 minutes.) |
Ah right, the |
#781 was the last problem we were running into; now it seems that we have everything to publish an |
Creating a proper manylinux python package is challenging for us due to rust's magika depending on ort, and ort requiring GLIBC >= 2.31 for pre-built binaries while the latest manylinux is 2_28. See #747.
For now, we implemented a hack (see #748) that should work well enough: we generate a generic "linux" python package (with an old ubuntu github runner), and then we patch it so that it looks like a manylinux package. This should work because the rust magika's binary only depend on very few ubiquitous libraries, and we don't expect problems in most cases.
That being said, more tests are needed to check how frequently this does not work.
The text was updated successfully, but these errors were encountered: