Skip to content
Snippets Groups Projects
Verified Commit c8454b7d authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: initial python module structure

parent 1ef4a9d1
No related branches found
No related tags found
1 merge request!36Support for Python
Pipeline #3593 passed
......@@ -16,6 +16,7 @@ crate-type = ["cdylib", "rlib"]
[features]
wasm = ["wasm-bindgen", "js-sys"]
python = ["pyo3"]
debug = []
pedantic = []
cpulog = []
......@@ -24,6 +25,7 @@ gen-mock = []
[dependencies]
wasm-bindgen = { version = "0.2", optional = true }
js-sys = { version = "0.3", optional = true }
pyo3 = { version = "0.20", optional = true }
[build-dependencies]
chrono = "0.4"
......
......@@ -20,3 +20,6 @@ pub mod state;
pub mod test;
pub mod timer;
pub mod util;
#[cfg(feature = "python")]
pub mod py;
use pyo3::prelude::*;
#[pyclass]
struct Boytacean {
#[pyo3(get, set)]
value: i32,
}
#[pymethods]
impl Boytacean {
#[new]
fn new(value: i32) -> Self {
Self { value }
}
pub fn add(&mut self, other: i32) {
self.value += other;
}
}
#[pymodule]
fn boytacean(_py: Python, module: &PyModule) -> PyResult<()> {
module.add_class::<Boytacean>()?;
Ok(())
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment