diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 32e4308..c8d3c3c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/Cargo.toml b/Cargo.toml index 39062f9..e585ea7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "python-daachorse" -version = "0.1.7" +version = "0.1.8" edition = "2021" authors = [ "Koichi Akabe ", @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 6492ec4..bc5490c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["maturin>=0.14,<0.15"] +requires = ["maturin>=1.0,<2.0"] build-backend = "maturin" [project] diff --git a/src/lib.rs b/src/lib.rs index 01404dc..ea0806d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use pyo3::{exceptions::PyValueError, prelude::*, types::PyUnicode}; +use pyo3::{exceptions::PyValueError, prelude::*, types::PyString}; use ::daachorse::{ CharwiseDoubleArrayAhoCorasick, CharwiseDoubleArrayAhoCorasickBuilder, MatchKind, @@ -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, match_kind: MatchKind, - patterns: Vec>, + patterns: Vec>, } #[pymethods] impl Automaton { #[new] - #[args(match_kind = "0")] - fn new(py: Python, patterns: Vec>, match_kind: u8) -> PyResult { - let raw_patterns: PyResult> = patterns - .iter() - .map(|pat| pat.as_ref(py).extract()) - .collect(); + #[pyo3(signature = (patterns, /, match_kind = 0))] + fn new(py: Python, patterns: Vec>, match_kind: u8) -> PyResult { + let raw_patterns: PyResult> = + patterns.iter().map(|pat| pat.extract(py)).collect(); let raw_patterns = raw_patterns?; let match_kind = MatchKind::from(match_kind); Ok(Self { @@ -142,7 +139,7 @@ impl Automaton { /// :type haystack: str /// :rtype: list[str] #[pyo3(text_signature = "($self, haystack, /)")] - fn find_as_strings(self_: PyRef, haystack: &str) -> PyResult>> { + fn find_as_strings(self_: PyRef, haystack: &str) -> PyResult>> { let match_kind = self_.match_kind; let py = self_.py(); let pma = &self_.pma; @@ -222,7 +219,7 @@ impl Automaton { fn find_overlapping_as_strings( self_: PyRef, haystack: &str, - ) -> PyResult>> { + ) -> PyResult>> { if self_.match_kind != MatchKind::Standard { return Err(PyValueError::new_err("match_kind must be STANDARD")); } @@ -314,7 +311,7 @@ impl Automaton { fn find_overlapping_no_suffix_as_strings( self_: PyRef, haystack: &str, - ) -> PyResult>> { + ) -> PyResult>> { if self_.match_kind != MatchKind::Standard { return Err(PyValueError::new_err("match_kind must be STANDARD")); } @@ -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::()?; m.add("MATCH_KIND_STANDARD", MatchKind::Standard as u8)?; m.add(