I'm looking for Info on how to structure a Python package that wraps an extension module written in Rust, where both languages are mixed. I'm using pyO3 for FFI but can't seem to find an example on how to do this. To be specific: my rust library exposes a type that is later wrapped by a python class. Only the python class should be exposed for later users and the package should be structured, such that it can be pushed to PyPI.
For example:
On the rust side
#[pyclass]
pub struct Point {
x: f64,
y: f64
}
#[pymethods]
impl Point {
#[new]
pub fn new(x: f64, y: f64) -> Self { Self{x, y} }
}
and on the python side
from ??? import Point
class Points:
points: List[Point]
def __init__(self, points: List[Tuple[float, float]]):
self.points = []
for point in points:
x, y = point
self.points.append(Point(x, y))
I would be thankful for any Infos, Sources, Examples etc.!