aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs16
-rw-r--r--src/pyo3_template/__init__.py0
-rw-r--r--src/pyo3_template/__main__.py8
-rw-r--r--src/pyo3_template/_core.pyi3
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