diff options
| author | 2025-03-12 21:32:29 +0800 | |
|---|---|---|
| committer | 2025-03-12 21:32:29 +0800 | |
| commit | dd873e954a92d0e3209fe98b034570b47c859589 (patch) | |
| tree | 4e1718f42394c9f3384b8f91429068a6e1e980db /src | |
| download | conventional_role_play-dd873e954a92d0e3209fe98b034570b47c859589.tar.gz conventional_role_play-dd873e954a92d0e3209fe98b034570b47c859589.zip | |
Initial commit
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 16 | ||||
| -rw-r--r-- | src/pyo3_template/__init__.py | 0 | ||||
| -rw-r--r-- | src/pyo3_template/__main__.py | 8 | ||||
| -rw-r--r-- | src/pyo3_template/_core.pyi | 3 |
4 files changed, 27 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..166cb09 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,16 @@ +use pyo3::prelude::*; + +#[pyfunction] +fn sum_as_string(a: usize, b: usize) -> PyResult<String> { + Ok((a + b).to_string()) +} + +#[pyclass] +pub struct Base {} + +#[pymodule] +fn _core(_py: Python<'_>, m: &PyModule) -> PyResult<()> { + m.add_function(wrap_pyfunction!(sum_as_string, m)?)?; + m.add_class::<Base>()?; + Ok(()) +}
\ No newline at end of file diff --git a/src/pyo3_template/__init__.py b/src/pyo3_template/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/pyo3_template/__init__.py diff --git a/src/pyo3_template/__main__.py b/src/pyo3_template/__main__.py new file mode 100644 index 0000000..0135c6d --- /dev/null +++ b/src/pyo3_template/__main__.py @@ -0,0 +1,8 @@ +from ._core import sum_as_string + +def main(): + print(sum_as_string(1, 2)) + + +if __name__ == "__main__": + main()
\ No newline at end of file diff --git a/src/pyo3_template/_core.pyi b/src/pyo3_template/_core.pyi new file mode 100644 index 0000000..4945a82 --- /dev/null +++ b/src/pyo3_template/_core.pyi @@ -0,0 +1,3 @@ +def sum_as_string(self, a: int, b: int) -> str: ... + +class Base: ...
\ No newline at end of file |
