Skip to content

Commit

Permalink
feat: add python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
ChieloNewctle committed May 9, 2024
1 parent 40b3b8b commit 0a9d03f
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
[package]
name = "mtc-token-healing"
[workspace]
members = ["python"]

[workspace.package]
version = "0.1.1"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Token healing implementation"
repository = "https://github.com/ModelTC/mtc-token-healing"
homepage = "https://github.com/ModelTC/mtc-token-healing"
documentation = "https://docs.rs/mtc-token-healing"

[package]
name = "mtc-token-healing"
version.workspace = true
edition.workspace = true
license.workspace = true
description.workspace = true
repository.workspace = true
homepage.workspace = true
documentation.workspace = true
readme = "README.md"
authors = ["Chielo Newctle <[email protected]>"]
exclude = ["release-plz.toml", ".github"]
Expand All @@ -32,3 +44,8 @@ tokio = { version = "1.37.0", features = ["rt-multi-thread"] }

[package.metadata.docs.rs]
all-features = true

[profile.release]
lto = true
strip = true
opt-level = "z"
17 changes: 17 additions & 0 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "mtc-token-healing-py"
version.workspace = true
edition.workspace = true
license.workspace = true
description.workspace = true
repository.workspace = true
homepage.workspace = true
documentation.workspace = true

[lib]
name = "mtc_token_healing"
crate-type = ["cdylib"]

[dependencies]
mtc-token-healing = { version = "0.1.0", path = "..", features = ["pyo3"] }
pyo3 = { version = "0.21.2", features = ["extension-module", "generate-import-lib", "abi3-py38"] }
5 changes: 5 additions & 0 deletions python/mtc_token_healing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .mtc_token_healing import CountInfo

__all__ = [
"CountInfo",
]
1 change: 1 addition & 0 deletions python/mtc_token_healing/mtc_token_healing.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class CountInfo: ...
16 changes: 16 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[build-system]
requires = ["maturin>=1.3,<2.0"]
build-backend = "maturin"

[project]
name = "mtc_token_healing"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = ["version"]

[project.optional-dependencies]
test = ["pytest"]
8 changes: 8 additions & 0 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use ::mtc_token_healing::CountInfo;
use pyo3::prelude::*;

#[pymodule]
fn mtc_token_healing(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<CountInfo>()?;
Ok(())
}

0 comments on commit 0a9d03f

Please sign in to comment.