diff options
| author | 2024-03-12 23:09:04 +0800 | |
|---|---|---|
| committer | 2024-03-12 23:09:04 +0800 | |
| commit | 6e555bf5c16815cf0982ba5891e3bbe09444091a (patch) | |
| tree | 5d07b274c2df520618387a13045e9e92d592ad00 | |
| parent | 91ebc76aec7ace1189d9a2386e167de0e080fc77 (diff) | |
| download | HydroRollCore-6e555bf5c16815cf0982ba5891e3bbe09444091a.tar.gz HydroRollCore-6e555bf5c16815cf0982ba5891e3bbe09444091a.zip | |
refactor(filetree): docs -> document, features -> feature, dev -> development
| -rw-r--r-- | hydro_roll_core/__init__.py | 3 | ||||
| -rw-r--r-- | hydro_roll_core/development/__init__.py (renamed from hydro_roll_core/dev/__init__.py) | 0 | ||||
| -rw-r--r-- | hydro_roll_core/document/__init__.py (renamed from hydro_roll_core/docs/__init__.py) | 0 | ||||
| -rw-r--r-- | hydro_roll_core/feature/__init__.py (renamed from hydro_roll_core/features/__init__.py) | 0 | ||||
| -rw-r--r-- | src/main.rs | 36 |
5 files changed, 38 insertions, 1 deletions
diff --git a/hydro_roll_core/__init__.py b/hydro_roll_core/__init__.py index 0a04e23..12508e3 100644 --- a/hydro_roll_core/__init__.py +++ b/hydro_roll_core/__init__.py @@ -1 +1,2 @@ -from . import corelib
\ No newline at end of file +from . import corelib + diff --git a/hydro_roll_core/dev/__init__.py b/hydro_roll_core/development/__init__.py index e69de29..e69de29 100644 --- a/hydro_roll_core/dev/__init__.py +++ b/hydro_roll_core/development/__init__.py diff --git a/hydro_roll_core/docs/__init__.py b/hydro_roll_core/document/__init__.py index e69de29..e69de29 100644 --- a/hydro_roll_core/docs/__init__.py +++ b/hydro_roll_core/document/__init__.py diff --git a/hydro_roll_core/features/__init__.py b/hydro_roll_core/feature/__init__.py index e69de29..e69de29 100644 --- a/hydro_roll_core/features/__init__.py +++ b/hydro_roll_core/feature/__init__.py diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..4c28efa --- /dev/null +++ b/src/main.rs @@ -0,0 +1,36 @@ +#![allow(unused)] +fn main() { + use pyo3::prelude::*; + + #[pymodule] + fn parent_module(py: Python<'_>, m: &PyModule) -> PyResult<()> { + register_child_module(py, m)?; + Ok(()) + } + + fn register_child_module(py: Python<'_>, parent_module: &PyModule) -> PyResult<()> { + let child_module = PyModule::new(py, "child_module")?; + child_module.add_function(wrap_pyfunction!(func, child_module)?)?; + parent_module.add_submodule(child_module)?; + Ok(()) + } + + #[pyfunction] + fn func() -> String { + "func".to_string() + } + + Python::with_gil(|py| { + use pyo3::types::IntoPyDict; + use pyo3::wrap_pymodule; + let parent_module = wrap_pymodule!(parent_module)(py); + let ctx = [("parent_module", parent_module)].into_py_dict(py); + + py.run( + "assert parent_module.child_module.func() == 'func'", + None, + Some(&ctx), + ) + .unwrap(); + }) +} |
