Hi, I'm not sure if anyone tried this yet, but I was thinking if it is possible to use pyo3 in a component, I would like to run a Rust program that calls into a python library when needed
since Google doesn't help I'm pretty sure there is no well-traveled path but has anyone looked into this yet?
You might want to look at componentize-py and/or spin-python-sdk, both of which use Py03 to bridge Rust and Python in a WASI guest. The key to making it work is building CPython to target WASI and setting the lib_dir
option in your Py03 config file to point to it, e.g. https://github.com/dicej/componentize-py/blob/7f7489dcae8104f501902854a901394c8a17c4c3/build.rs#L222-L248.
oh I didn't realize componentize actually uses pyo3, thank you I will have a deeper look :)
side question, is there any update on supporting the new wit format with packages?
The snapshot
branch in the componentize-py
repo uses the new WIT format, but that branch also includes native extension support (i.e. the "pseudo-dynamic linking" stuff I mentioned above), which depends on toolchain changes which haven't been upstreamed yet. I'm hoping to work on that later this week. The WIT-related changes could probably be backported to the main branch, but I'm not sure that's worth the effort.
I agree backporting is too much effort, thanks a lot for the progress report :) I hope upstream merges will go smoothly
Ramon Klass has marked this topic as resolved.
@Ramon Klass if you're interested in keeping up with the progress on Python. @Joel Dice and @Kevin Smith are the organizers of the Python Subgroup of the Guest Languages SIG and they meet as a group on an every other week cadence to talk about Python guest work.
I'm generally interested, I wasn't sure how open those meetings are and never dared to sign up for one
no harm in dropping in to find out!
I'd love to see more interested folks show up!
All meetings for SIG Guest Languages and its subgroups are fully open to the public. You're welcome to join us!
Last updated: Dec 23 2024 at 12:05 UTC