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
//! Python bindings — `PyO3` 0.22 `extension-module`, like `ort.py`.
//!
//! This crate is the Python extension for `pmmlruntime` (`import pmml_runtime`).
//! Currently a stub that reserves the crate name and exposes a trivial `hello()` for smoke tests.
//! May expose `#[pyclass] InferenceSession` wrapping `crate::session::Session` with
//! `new(path)`, `run(dict)`, and `run_batch(list[dict])` plus `__repr__`.
//!
//! # Feature flags
//!
//! - `python` — enables `pyo3` 0.22 with `extension-module`. Without the feature, `pyo3` is not linked
//! and the crate is a no-op (so `cargo test --workspace` doesn't need `libpython`).
//!
//! # What belongs here
//!
//! - `python_impl` module (`#[cfg(feature = "python")]`) with `#[pyfunction] hello` and `#[pymodule] pmml_runtime`.
//! - Future `InferenceSession` pyclass that owns `Session` and `PmmlEnv`.
//!
//! # Thread safety
//!
//! `PyO3` requires `Send` for `#[pyclass]`. `crate::session::Session` is already `Send+Sync`, so `InferenceSession` will be too.
//! GIL handling will use `py.allow_threads(|| sess.run(...))` to avoid blocking Python.
//!
//! # Examples
//!
//! ```python
//! # Python (not Rust):
//! # import pmml_runtime
//! # print(pmml_runtime.hello()) # -> "pmml-runtime"
//! ```
//!
//! # Rust example (placeholder)
//!
//! ```
//! // This crate currently has only placeholder()
//! assert_eq!(pmmlruntime::python::placeholder(), ());
//! ```
// Future:
// use pyo3::prelude::*;
// #[pyclass] struct InferenceSession { inner: crate::session::Session }
// #[pymethods] impl InferenceSession { fn new(path: &str) -> ...; fn run(...) }
/// Placeholder to keep crate non-empty when `python` feature is off.
///
/// Always available so `cargo doc` / `cargo test` without `python` feature still link.
/// Python module implementation gated on `python` feature.
///
/// Exposes `pyo3` 0.22 `extension-module` with `#[pymodule] pmml_runtime`.
/// When the feature is off this module is not compiled, so `libpython` is not required.