Compile UniFFI interfaces defined in sibling libraries
Hey folks,
I'm currently trying to adopt Maturin in my monorepo, which is attempting to use UniFFI to export FFI interfaces for Kotlin and Python from a shared Rust crate (odict). The core library is setup to use FFI, and upon compiling will produce a .py file in the target directory:
However, because Maturin expects you to be building your UniFFI interface from the current project, it's looking for pyodict.py (the Python library/binding where I'm using Maturin).
This file doesn't exist and causes an error:
I'd love it if Maturin would allow you to create wheels from shared FFIs like this, instead of forcing you to keep it all in a single project. I combed the docs but couldn't find a way to do this. Hopefully I'm not missing something.
Unfortunately the generated python file name can only be inferred from cdylib_name config in uniffi.toml so you'd need to change it to odict to match the .py file.
Hey @messense, thanks for the response. I had a uniffi.toml, but I think I had my config wrong. That said, I just replaced it (python/uniffi.toml) with this:
[bindings.python]
cdylib_name = "odict"
and running Maturin it's still looking for pyodict. Is there something else I need to do?
Can you try change this to odict as well?
https://github.com/TheOpenDictionary/odict/blob/ffbfacb6e531421ef6a9cafbe852e321e2b666ce/python/Cargo.toml#L7
So I actually tried that, and I believe Rust complains if there are two crates that produce libraries with the same name. Away from my keyboard at the moment, but I can safely say it errored and failed to build when I tried that :/
@messense Any further suggestions? 🥺