-
Notifications
You must be signed in to change notification settings - Fork 418
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
Convert python API into a dynamic-link library for Linux #679
Comments
I believe the rust library would be useful for this use case? /cc @ia0? |
I'm not sure I fully understand the initial question. There's at least 2 ways to interpret it for someone like me unfamiliar with Python:
So I guess the best would be to know what the problem is rather than what a possible solution could be (XY problem). @7012xxx could you help us understand what you are trying to do for which you believe a dynamic library could help? Thanks! |
Thank you for your reply. I am looking to use Magika in an environment that does not have Python >=3.8. Additionally, I want to call Magika using both Golang and Python. During my research, I discovered that dynamic link libraries might meet my needs, enabling seamless calls between Golang and Python. |
Thanks, so it looks like for the Golang use-case, we have something planned: Providing a C API to the Rust library (ideally as both a static and dynamic library). But this still needs to be done. For the Python use-case, either the same library could be used (although since Python is not a compiled language, the static library probably won't be an option), or we could provide Python bindings to the Rust library using PyO3 and Maturin. This too would need to be designed and implemented. You can follow #96 for the Golang use-case. For Python, we'll have to decide if we go with C (thus #90) or with PyO3 (which would required a new issue). |
My take for the python part (feedback is welcome):
@7012xxx: would the ctypes route around an .so file work for you? |
For Rust in general yes, but for this particular case depending on ONNX through the ort crate, I don't know. We would need to test it, but it's indeed part of the plan to try. I expect a static library to be simpler. I'm expecting to track this in #90. |
I am eager to obtain the cdylib (i.e., so file) I need by using Rust. However, I lack relevant background knowledge in Rust. During the compilation process, I ran into a problem. Namely, I can't directly generate the so file under the /rust directory via "cargo build --release". It prompts me that the toml file needs to be edited. After several attempts after editing, I still can't successfully compile. Could you please provide a toml file example or help me compile magika into an so file? |
I want to use Magika without relying on any other libraries and language environments. |
Here's an example on how to build a dynamic library in Rust and use it from C. Ultimately we'll build such a |
I'm following up here instead of by email because others might be to help you much better than me.
In particular, did you manage to successfully run |
I can successfully complete the compilation of the |
It looks to me like a problem with your platform. Maybe it's too old or it's missing some library. If you can't resolve it on your own, your best bet is to wait until we support this use-case. This is currently not supported. |
The following are my Linux platform parameters.
The following is the dependency relationship of the libmagika_api.so that I compiled. As can be seen, libstdc++.so.6 has been installed.
It appears that everything seems to be in order. As a result, I truly cannot determine if there are any missing partial dependent libraries. Do you have any suggestions?
Is there a compatibility issue between the C++ standard library and GCC here? |
@ia0 Could you provide the platform parameters when you compile with cargo? For example, the C++ version and Linux version. Also, which libraries does the compiled |
How can I build this Python API into a dynamic-link library for Linux, generating a file with the suffix '.so'?
The text was updated successfully, but these errors were encountered: