chitralverma opened a new pull request, #7812: URL: https://github.com/apache/opendal/pull/7812
# Which issue does this PR close? Closes #. # Rationale for this change The Python binding built its submodules (`operator`, `file`, `capability`, `services`, `layers`, `types`, `exceptions`) imperatively via the `add_pymodule!` / `add_pyexceptions!` macros and a `fn`-based `#[pymodule]`. PyO3 recommends the declarative `#[pymodule] mod ...` form with `#[pymodule_export]` ([PyO3 module guide](https://pyo3.rs/v0.29.0/module.html)). This PR moves the binding to that style. # What changes are included in this PR? - `_opendal` is now a `#[pymodule] mod` with one nested `#[pymodule] mod` per submodule; classes are attached with `#[pymodule_export]`. - `__version__` is exported as a `#[pymodule_export] pub const` instead of being set in an init function. - Replaced the `add_pymodule!` / `add_pyexceptions!` macros with a `register_in_sys` helper (registers each submodule in `sys.modules` and sets its `__name__`) and an `add_exceptions!` macro. - The exceptions submodule adds its members procedurally, since `create_exception!` types are `PyErr` subtypes rather than `#[pyclass]`es and cannot use `#[pymodule_export]`. - Refreshed `uv.lock`. > Note: `cargo run --bin stub_gen` already fails on `main` (independent of this change) and is not addressed here; it will be fixed in a future PR. # Are there any user-facing changes? No API changes. One minor behavioral correction: submodule `__name__` is now the fully qualified dotted name (e.g. `opendal.operator`) instead of the bare name (`operator`), matching the `sys.modules` key, the classes' `__module__`, and standard-library conventions. All public imports (`from opendal import Operator`, `from opendal.exceptions import NotFound`, etc.) and `opendal.__version__` are unchanged. # AI Usage Statement -- 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]
