실제 러스트 모듈 초기 진입점은 rust/src/lib.rs 에 있는 #[pymodule(name="engine")]
여기에 이런식으로 클래스 등을 추가
fn init_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
m.add_class::<ml_v5::RRCFAnomalyPredictorV5>()?;
m.add_function(wrap_pyfunction!(util::gen_search_key_py, m)?)?;
Ok(())
}
[tool.maturin]
profile = "release"
module-name = "anomaly_engine.engine"
features = ["pyo3/abi3-py312"]
auditwheel = "repair"
manifest-path = "src/ml5/rust/Cargo.toml"
python-source = "src"
이렇게 하고 uv build
하면 src에서 anomaly_engine 디렉토리를 찾는 로그를 볼 수 있음.
anomaly_engine 디렉토리가 필요하고 그안에서 다음과 같이 임포트 가능
from anomaly_engine.engine import RRCFAnomalyPredictorV5