1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! Python module registration and submodule wiring.
//!
//! This module defines the PyO3 module structure exposed to Python. It registers
//! the root `_lib` module and all submodules, setting up the correct `sys.modules`
//! paths for Python's import system.
//!
//! # Module Hierarchy
//!
//! The bindings are structured as follows:
//!
//! ```text
//! rscm._lib # Root module (this file)
//! ├── core # Core abstractions from rscm-core
//! │ ├── spatial # Spatial grid types
//! │ └── state # State value types
//! ├── components # Generic components from rscm-components
//! ├── two_layer # Two-layer model from rscm-two-layer
//! └── magicc # MAGICC components from rscm-magicc
//! ```
//!
//! # Implementation Details
//!
//! PyO3 submodules require explicit registration in Python's `sys.modules` dictionary
//! to enable `from rscm._lib.submodule import X` syntax. The `set_path` and
//! `set_submodule_path` helper functions handle this registration.
//!
//! Each submodule is defined in its respective crate:
//!
//! - `core` module: [`rscm_core::python::core`]
//! - `components` module: [`rscm_components::python::components`]
//! - `two_layer` module: [`rscm_two_layer::python::two_layer`]
//! - `magicc` module: [`rscm_magicc::python::magicc`]
use *;
use wrap_pymodule;
use components;
use core;
use magicc;
use two_layer;
use CString;
/// Root Python module for RSCM bindings.
///
/// This function is called by PyO3 when the module is imported. It registers
/// all submodules and sets up the Python import paths.
/// Register a submodule in Python's `sys.modules` dictionary.
///
/// This enables `from rscm._lib.{module} import X` syntax by making the
/// submodule discoverable through Python's import machinery.
///
/// # Arguments
///
/// * `m` - The parent module bound to Python
/// * `path` - The full dotted path to register (e.g., "rscm._lib.core")
/// * `module` - The local module name (e.g., "core")
/// Register a nested submodule in Python's `sys.modules` dictionary.
///
/// Similar to [`set_path`], but for submodules nested within another submodule
/// (e.g., `rscm._lib.core.spatial`).
///
/// # Arguments
///
/// * `m` - The root module bound to Python
/// * `path` - The full dotted path to register (e.g., "rscm._lib.core.spatial")
/// * `parent` - The parent module name (e.g., "core")
/// * `submodule` - The submodule name (e.g., "spatial")