chitralverma commented on code in PR #6690:
URL: https://github.com/apache/opendal/pull/6690#discussion_r2439517925
##########
bindings/python/src/utils.rs:
##########
@@ -73,3 +73,45 @@ impl Buffer {
Ok(())
}
}
+
+/// Macro to create and register a PyO3 submodule with multiple classes.
+///
+/// Example:
+/// ```rust
+/// add_pymodule!(py, m, "services", [PyScheme, PyOtherClass]);
+/// ```
+#[macro_export]
+macro_rules! add_pymodule {
+ ($py:expr, $parent:expr, $name:expr, [$($cls:ty),* $(,)?]) => {{
+ let sub_module = pyo3::types::PyModule::new($py, $name)?;
+ $(
+ sub_module.add_class::<$cls>()?;
+ )*
Review Comment:
will be useful for other stubs later.
- Adds class to pyo3 module
- defined python package(see
https://github.com/PyO3/pyo3/issues/1517#issuecomment-808664021)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]