Crates.io | cargo-wheel |
lib.rs | cargo-wheel |
version | 0.2.2 |
source | src |
created_at | 2018-11-24 13:23:09.894942 |
updated_at | 2023-03-25 15:23:36.601095 |
description | Deprecated - Use milksnake and cbindgen to generate python binding to your Rust crate. |
homepage | |
repository | https://github.com/pacman82/cargo-wheel.git |
max_upload_size | |
id | 98429 |
size | 49,821 |
Use milksnake and cbindgen to generate python binding to your Rust crate.
Deprecated
milksnake has not seen many updates in the last year and seems to have been replaced by maturin. I would not recommend using this crate anymore.
Edit your Cargo.toml
and set the crate type to cdylib
[lib]
crate-type = ["cdylib"]
Export functions or datastructures in your library to make them visible to C
.
#[no_mangle]
pub extern fn greet() {
println!("Hello from Rust");
}
Call cargo wheel
to invoke cbindgen and set up a python package.
cargo wheel
Use cffi
in the generated __init__.py
to expose the functionality to python
from test_lib._native import ffi, lib
def greet():
lib.greet()
To save boilerplate if creating python bindings for a Rust crate
Scenarios where you want to invoke cargo
from your setup.py
rather than the other way around.
E.g. If you want to replace python code with Rust in an existing wheel.