From b3d02fa99850085ec6a8769c4b09dfe88461aea6 Mon Sep 17 00:00:00 2001 From: Koichi Akabe Date: Thu, 13 Mar 2025 12:05:57 +0900 Subject: [PATCH 1/4] Add support for Python 3.12 and 3.13, remove 3.7 and 3.8 --- .github/workflows/CI.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 32e4308..55ef7a1 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 @@ -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 From 0dc4fa40dd4161572911a09d5f8219785fcd5e62 Mon Sep 17 00:00:00 2001 From: Koichi Akabe Date: Thu, 13 Mar 2025 12:10:01 +0900 Subject: [PATCH 2/4] update maturin --- .github/workflows/CI.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 55ef7a1..c8d3c3c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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 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] From ed48615a5f71db90855057c27edeb57f4cc2e8cd Mon Sep 17 00:00:00 2001 From: Koichi Akabe Date: Thu, 13 Mar 2025 12:11:03 +0900 Subject: [PATCH 3/4] update maturin --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From c24aafa5b8dfdd20cd793effe8b111aaab6f69a4 Mon Sep 17 00:00:00 2001 From: Koichi Akabe Date: Thu, 13 Mar 2025 14:38:15 +0900 Subject: [PATCH 4/4] fix --- src/lib.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) 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(