Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
runs-on: [ ubuntu-latest, windows-latest, macos-latest ]
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.13'
- uses: dtolnay/rust-toolchain@stable
- name: Build package
uses: PyO3/maturin-action@v1
Expand All @@ -62,7 +62,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
target: [ x86_64, i686 ]
steps:
- uses: actions/checkout@v3
Expand All @@ -88,7 +88,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
target: [ x64, x86 ]
steps:
- uses: actions/checkout@v3
Expand All @@ -115,7 +115,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "python-daachorse"
version = "0.1.7"
version = "0.1.8"
edition = "2021"
authors = [
"Koichi Akabe <vbkaisetsu@gmail.com>",
Expand All @@ -17,7 +17,7 @@ crate-type = ["cdylib"]

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

[profile.release]
lto = true
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.14,<0.15"]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[project]
Expand Down
23 changes: 10 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pyo3::{exceptions::PyValueError, prelude::*, types::PyUnicode};
use pyo3::{exceptions::PyValueError, prelude::*, types::PyString};

use ::daachorse::{
CharwiseDoubleArrayAhoCorasick, CharwiseDoubleArrayAhoCorasickBuilder, MatchKind,
Expand All @@ -19,22 +19,19 @@ use ::daachorse::{
/// :type match_kind: int
/// :rtype: daachorse.Automaton
#[pyclass]
#[pyo3(text_signature = "(patterns, /, match_kind = daachorse.MATCH_KIND_STANDARD)")]
struct Automaton {
pma: CharwiseDoubleArrayAhoCorasick<usize>,
match_kind: MatchKind,
patterns: Vec<Py<PyUnicode>>,
patterns: Vec<Py<PyString>>,
}

#[pymethods]
impl Automaton {
#[new]
#[args(match_kind = "0")]
fn new(py: Python, patterns: Vec<Py<PyUnicode>>, match_kind: u8) -> PyResult<Self> {
let raw_patterns: PyResult<Vec<String>> = patterns
.iter()
.map(|pat| pat.as_ref(py).extract())
.collect();
#[pyo3(signature = (patterns, /, match_kind = 0))]
fn new(py: Python, patterns: Vec<Py<PyString>>, match_kind: u8) -> PyResult<Self> {
let raw_patterns: PyResult<Vec<String>> =
patterns.iter().map(|pat| pat.extract(py)).collect();
let raw_patterns = raw_patterns?;
let match_kind = MatchKind::from(match_kind);
Ok(Self {
Expand Down Expand Up @@ -142,7 +139,7 @@ impl Automaton {
/// :type haystack: str
/// :rtype: list[str]
#[pyo3(text_signature = "($self, haystack, /)")]
fn find_as_strings(self_: PyRef<Self>, haystack: &str) -> PyResult<Vec<Py<PyUnicode>>> {
fn find_as_strings(self_: PyRef<Self>, haystack: &str) -> PyResult<Vec<Py<PyString>>> {
let match_kind = self_.match_kind;
let py = self_.py();
let pma = &self_.pma;
Expand Down Expand Up @@ -222,7 +219,7 @@ impl Automaton {
fn find_overlapping_as_strings(
self_: PyRef<Self>,
haystack: &str,
) -> PyResult<Vec<Py<PyUnicode>>> {
) -> PyResult<Vec<Py<PyString>>> {
if self_.match_kind != MatchKind::Standard {
return Err(PyValueError::new_err("match_kind must be STANDARD"));
}
Expand Down Expand Up @@ -314,7 +311,7 @@ impl Automaton {
fn find_overlapping_no_suffix_as_strings(
self_: PyRef<Self>,
haystack: &str,
) -> PyResult<Vec<Py<PyUnicode>>> {
) -> PyResult<Vec<Py<PyString>>> {
if self_.match_kind != MatchKind::Standard {
return Err(PyValueError::new_err("match_kind must be STANDARD"));
}
Expand All @@ -333,7 +330,7 @@ impl Automaton {
}

#[pymodule]
fn daachorse(_py: Python, m: &PyModule) -> PyResult<()> {
fn daachorse(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<Automaton>()?;
m.add("MATCH_KIND_STANDARD", MatchKind::Standard as u8)?;
m.add(
Expand Down