#![allow(deprecated)] use pyo3::{
prelude::*,
types::{PyDict, PyString},
};
#[pymodule]
fn nautilus_pyo3(py: Python<'_>, m: &PyModule) -> PyResult<()> {
let sys = PyModule::import(py, "sys")?;
let sys_modules: &PyDict = sys.getattr("modules")?.downcast()?;
let module_name = "nautilus_trader.core.nautilus_pyo3";
sys_modules.set_item(module_name, m)?;
let n = "databento";
let submodule = pyo3::wrap_pymodule!(nautilus_adapters::databento::python::databento);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
let n = "core";
let submodule = pyo3::wrap_pymodule!(nautilus_core::python::core);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
let n = "common";
let submodule = pyo3::wrap_pymodule!(nautilus_common::python::common);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
let n = "crypto";
let submodule = pyo3::wrap_pymodule!(nautilus_adapters::crypto::python::crypto);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
let n = "model";
let submodule = pyo3::wrap_pymodule!(nautilus_model::python::model);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
let n = "indicators";
let submodule = pyo3::wrap_pymodule!(nautilus_indicators::python::indicators);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
let n = "infrastructure";
let submodule = pyo3::wrap_pymodule!(nautilus_infrastructure::python::infrastructure);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
let n = "network";
let submodule = pyo3::wrap_pymodule!(nautilus_network::python::network);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
let n = "persistence";
let submodule = pyo3::wrap_pymodule!(nautilus_persistence::python::persistence);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
let n = "test_kit";
let submodule = pyo3::wrap_pymodule!(nautilus_test_kit::python::test_kit);
m.add_wrapped(submodule)?;
sys_modules.set_item(format!("{module_name}.{n}"), m.getattr(n)?)?;
re_export_module_attributes(m, n)?;
Ok(())
}
fn re_export_module_attributes(parent_module: &PyModule, submodule_name: &str) -> PyResult<()> {
let submodule = parent_module.getattr(submodule_name)?;
for item in submodule.dir() {
let item_name: &PyString = item.extract()?;
if let Ok(attr) = submodule.getattr(item_name) {
parent_module.add(item_name.to_str()?, attr)?;
}
}
Ok(())
}