generated from PlexSheep/baserepo
devel #73
|
@ -54,12 +54,12 @@ categories.workspace = true
|
|||
[features]
|
||||
default = ["log", "core"]
|
||||
core = []
|
||||
full = ["default", "core", "math", "log", "bintols", "net", "py"]
|
||||
full = ["default", "core", "math", "log", "bintols", "net"]
|
||||
math = ["dep:libpt-math", "log"]
|
||||
log = ["dep:libpt-log"]
|
||||
bintols = ["dep:libpt-bintols", "log"]
|
||||
net = ["dep:libpt-net", "log"]
|
||||
py = ["dep:libpt-py"]
|
||||
# py = ["dep:libpt-py"]
|
||||
|
||||
[lib]
|
||||
name = "libpt"
|
||||
|
@ -75,4 +75,3 @@ libpt-bintols = { workspace = true, optional = true }
|
|||
libpt-log = { workspace = true, optional = true }
|
||||
libpt-math = { workspace = true, optional = true }
|
||||
libpt-net = { workspace = true, optional = true }
|
||||
libpt-py = { workspace = true, optional = true }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "libpt-py"
|
||||
version = "0.3.11"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[package.metadata.maturin]
|
||||
|
@ -11,4 +11,14 @@ name = "libpt"
|
|||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
libpt = { version = "0.3.11", path = "../.." }
|
||||
pyo3 = "0.19.0"
|
||||
|
||||
[features]
|
||||
default = ["log", "core", "full"]
|
||||
core = []
|
||||
full = ["default", "core", "math", "log", "bintols", "net"]
|
||||
math = ["libpt/math", "log"]
|
||||
log = ["libpt/log"]
|
||||
bintols = ["libpt/bintols", "log"]
|
||||
net = ["libpt/net", "log"]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
use pyo3::prelude::*;
|
||||
|
||||
/// implement a python module in Rust
|
||||
#[pymodule]
|
||||
#[pyo3(name = "core")]
|
||||
pub fn submodule(py: Python, m: &PyModule) -> PyResult<()> {
|
||||
let submodule = PyModule::new(py, "submodule")?;
|
||||
submodule.add("super_useful_constant", "important")?;
|
||||
m.add_submodule(m)?;
|
||||
Ok(())
|
||||
}
|
|
@ -1,15 +1,23 @@
|
|||
//! Python bindings for [`libpt`](libpt)
|
||||
use libpt;
|
||||
|
||||
#[cfg(feature = "core")]
|
||||
mod core;
|
||||
|
||||
use pyo3::prelude::*;
|
||||
|
||||
/// Formats the sum of two numbers as string.
|
||||
/// return the version of libpt
|
||||
#[pyfunction]
|
||||
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
|
||||
Ok((a + b).to_string())
|
||||
fn version() -> String {
|
||||
env!("CARGO_PKG_VERSION").to_string()
|
||||
}
|
||||
|
||||
/// A Python module implemented in Rust.
|
||||
/// implement a python module in Rust
|
||||
#[pymodule]
|
||||
#[pyo3(name = "libpt")]
|
||||
fn libpt_py(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
|
||||
fn libpt_py(py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(version, m)?)?;
|
||||
#[cfg(feature = "core")]
|
||||
core::submodule(py, m)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Reference in New Issue