Skip to content

Commit 434b32e

Browse files
committed
Update for python3.13
1 parent c248742 commit 434b32e

File tree

3 files changed

+48
-138
lines changed

3 files changed

+48
-138
lines changed

Cargo.lock

Lines changed: 27 additions & 119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2018"
88
tokenizations = "0.4.2"
99

1010
[dependencies.pyo3]
11-
version = "^0.20.0"
11+
version = "^0.24.0"
1212
features = ["extension-module"]
1313

1414
[lib]

src/lib.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
22
use pyo3::prelude::*;
33
use tokenizations::{get_alignments, get_charmap, Alignment, CharMap};
44

5+
#[pyfunction]
6+
#[pyo3(name = "get_alignments")]
7+
pub fn get_alignments_py(
8+
a: Vec<String>,
9+
b: Vec<String>,
10+
) -> PyResult<(Alignment, Alignment)> {
11+
let a_refs: Vec<&str> = a.iter().map(|s| s.as_str()).collect();
12+
let b_refs: Vec<&str> = b.iter().map(|s| s.as_str()).collect();
13+
Ok(get_alignments(&a_refs, &b_refs))
14+
}
15+
16+
#[pyfunction]
17+
#[pyo3(name = "get_charmap")]
18+
pub fn get_charmap_py(a: String, b: String) -> PyResult<(CharMap, CharMap)> {
19+
Ok(get_charmap(&a, &b))
20+
}
21+
522
#[pymodule]
623
#[pyo3(name = "tokenizations")]
7-
fn tokenizations_(_py: Python, m: &PyModule) -> PyResult<()> {
24+
fn tokenizations_(m: &Bound<'_, PyModule>) -> PyResult<()> {
825
m.add("__version__", "0.9.1")?;
9-
10-
#[pyfn(m)]
11-
#[pyo3(name = "get_alignments")]
12-
pub fn get_alignments_py(
13-
_py: Python,
14-
a: Vec<&str>,
15-
b: Vec<&str>,
16-
) -> PyResult<(Alignment, Alignment)> {
17-
Ok(get_alignments(&a, &b))
18-
}
19-
20-
#[pyfn(m)]
21-
#[pyo3(name = "get_charmap")]
22-
pub fn get_charmap_py(_py: Python, a: &str, b: &str) -> PyResult<(CharMap, CharMap)> {
23-
Ok(get_charmap(a, b))
24-
}
25-
26+
m.add_function(wrap_pyfunction!(get_alignments_py, m)?)?;
27+
m.add_function(wrap_pyfunction!(get_charmap_py, m)?)?;
2628
Ok(())
2729
}

0 commit comments

Comments
 (0)