Skip to content

Commit 79fdf14

Browse files
authored
Add support for Python 3.12 and 3.13, remove 3.7 and 3.8 (#9)
* Add support for Python 3.12 and 3.13, remove 3.7 and 3.8 * update maturin * update maturin * fix
1 parent 328e438 commit 79fdf14

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
runs-on: [ ubuntu-latest, windows-latest, macos-latest ]
18-
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
18+
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
1919
runs-on: ${{ matrix.runs-on }}
2020
steps:
2121
- uses: actions/checkout@v3
@@ -44,7 +44,7 @@ jobs:
4444
- uses: actions/checkout@v3
4545
- uses: actions/setup-python@v4
4646
with:
47-
python-version: '3.11'
47+
python-version: '3.13'
4848
- uses: dtolnay/rust-toolchain@stable
4949
- name: Build package
5050
uses: PyO3/maturin-action@v1
@@ -62,7 +62,7 @@ jobs:
6262
runs-on: ubuntu-latest
6363
strategy:
6464
matrix:
65-
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
65+
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
6666
target: [ x86_64, i686 ]
6767
steps:
6868
- uses: actions/checkout@v3
@@ -88,7 +88,7 @@ jobs:
8888
runs-on: windows-latest
8989
strategy:
9090
matrix:
91-
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
91+
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
9292
target: [ x64, x86 ]
9393
steps:
9494
- uses: actions/checkout@v3
@@ -115,7 +115,7 @@ jobs:
115115
runs-on: macos-latest
116116
strategy:
117117
matrix:
118-
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
118+
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
119119
steps:
120120
- uses: actions/checkout@v3
121121
- uses: actions/setup-python@v4

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "python-daachorse"
3-
version = "0.1.7"
3+
version = "0.1.8"
44
edition = "2021"
55
authors = [
66
"Koichi Akabe <[email protected]>",
@@ -17,7 +17,7 @@ crate-type = ["cdylib"]
1717

1818
[dependencies]
1919
daachorse = "1.0.0" # MIT or Apache-2.0
20-
pyo3 = { version = "0.18.0", features = ["extension-module"] } # Apache-2.0
20+
pyo3 = { version = "0.24.0", features = ["extension-module"] } # Apache-2.0
2121

2222
[profile.release]
2323
lto = true

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["maturin>=0.14,<0.15"]
2+
requires = ["maturin>=1.0,<2.0"]
33
build-backend = "maturin"
44

55
[project]

src/lib.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use pyo3::{exceptions::PyValueError, prelude::*, types::PyUnicode};
1+
use pyo3::{exceptions::PyValueError, prelude::*, types::PyString};
22

33
use ::daachorse::{
44
CharwiseDoubleArrayAhoCorasick, CharwiseDoubleArrayAhoCorasickBuilder, MatchKind,
@@ -19,22 +19,19 @@ use ::daachorse::{
1919
/// :type match_kind: int
2020
/// :rtype: daachorse.Automaton
2121
#[pyclass]
22-
#[pyo3(text_signature = "(patterns, /, match_kind = daachorse.MATCH_KIND_STANDARD)")]
2322
struct Automaton {
2423
pma: CharwiseDoubleArrayAhoCorasick<usize>,
2524
match_kind: MatchKind,
26-
patterns: Vec<Py<PyUnicode>>,
25+
patterns: Vec<Py<PyString>>,
2726
}
2827

2928
#[pymethods]
3029
impl Automaton {
3130
#[new]
32-
#[args(match_kind = "0")]
33-
fn new(py: Python, patterns: Vec<Py<PyUnicode>>, match_kind: u8) -> PyResult<Self> {
34-
let raw_patterns: PyResult<Vec<String>> = patterns
35-
.iter()
36-
.map(|pat| pat.as_ref(py).extract())
37-
.collect();
31+
#[pyo3(signature = (patterns, /, match_kind = 0))]
32+
fn new(py: Python, patterns: Vec<Py<PyString>>, match_kind: u8) -> PyResult<Self> {
33+
let raw_patterns: PyResult<Vec<String>> =
34+
patterns.iter().map(|pat| pat.extract(py)).collect();
3835
let raw_patterns = raw_patterns?;
3936
let match_kind = MatchKind::from(match_kind);
4037
Ok(Self {
@@ -142,7 +139,7 @@ impl Automaton {
142139
/// :type haystack: str
143140
/// :rtype: list[str]
144141
#[pyo3(text_signature = "($self, haystack, /)")]
145-
fn find_as_strings(self_: PyRef<Self>, haystack: &str) -> PyResult<Vec<Py<PyUnicode>>> {
142+
fn find_as_strings(self_: PyRef<Self>, haystack: &str) -> PyResult<Vec<Py<PyString>>> {
146143
let match_kind = self_.match_kind;
147144
let py = self_.py();
148145
let pma = &self_.pma;
@@ -222,7 +219,7 @@ impl Automaton {
222219
fn find_overlapping_as_strings(
223220
self_: PyRef<Self>,
224221
haystack: &str,
225-
) -> PyResult<Vec<Py<PyUnicode>>> {
222+
) -> PyResult<Vec<Py<PyString>>> {
226223
if self_.match_kind != MatchKind::Standard {
227224
return Err(PyValueError::new_err("match_kind must be STANDARD"));
228225
}
@@ -314,7 +311,7 @@ impl Automaton {
314311
fn find_overlapping_no_suffix_as_strings(
315312
self_: PyRef<Self>,
316313
haystack: &str,
317-
) -> PyResult<Vec<Py<PyUnicode>>> {
314+
) -> PyResult<Vec<Py<PyString>>> {
318315
if self_.match_kind != MatchKind::Standard {
319316
return Err(PyValueError::new_err("match_kind must be STANDARD"));
320317
}
@@ -333,7 +330,7 @@ impl Automaton {
333330
}
334331

335332
#[pymodule]
336-
fn daachorse(_py: Python, m: &PyModule) -> PyResult<()> {
333+
fn daachorse(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
337334
m.add_class::<Automaton>()?;
338335
m.add("MATCH_KIND_STANDARD", MatchKind::Standard as u8)?;
339336
m.add(

0 commit comments

Comments
 (0)