diff --git a/.github/workflows/pyo3-wheels.yml b/.github/workflows/pyo3-wheels.yml index c40349e..acd8631 100644 --- a/.github/workflows/pyo3-wheels.yml +++ b/.github/workflows/pyo3-wheels.yml @@ -18,6 +18,10 @@ on: permissions: contents: read +env: + BASE: --out dist -m ua-parser-py/Cargo.toml + COMMON: --release --out dist -m ua-parser-py/Cargo.toml + jobs: linux: runs-on: ${{ matrix.platform.runner }} @@ -26,12 +30,12 @@ jobs: platform: - runner: ubuntu-latest target: x86_64 - - runner: ubuntu-latest - target: x86 + #- runner: ubuntu-latest + # target: x86 - runner: ubuntu-latest target: aarch64 - - runner: ubuntu-latest - target: armv7 + #- runner: ubuntu-latest + # target: armv7 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -41,7 +45,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist --zig + args: ${{ env.COMMON }} --zig sccache: 'true' manylinux: auto - name: Upload wheels @@ -57,12 +61,12 @@ jobs: platform: - runner: ubuntu-latest target: x86_64 - - runner: ubuntu-latest - target: x86 + #- runner: ubuntu-latest + # target: x86 - runner: ubuntu-latest target: aarch64 - - runner: ubuntu-latest - target: armv7 + #- runner: ubuntu-latest + # target: armv7 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -72,7 +76,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist + args: ${{ env.COMMON }} sccache: 'true' manylinux: musllinux_1_2 - name: Upload wheels @@ -88,8 +92,8 @@ jobs: platform: - runner: windows-latest target: x64 - - runner: windows-latest - target: x86 + #- runner: windows-latest + # target: x86 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -100,7 +104,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist + args: ${{ env.COMMON }} sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v4 @@ -113,9 +117,9 @@ jobs: strategy: matrix: platform: - - runner: macos-12 + - runner: macos-13 target: x86_64 - - runner: macos-14 + - runner: macos-13 target: aarch64 steps: - uses: actions/checkout@v4 @@ -126,7 +130,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.platform.target }} - args: --release --out dist + args: ${{ env.COMMON }} sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v4 @@ -142,7 +146,7 @@ jobs: uses: PyO3/maturin-action@v1 with: command: sdist - args: --out dist + args: ${{ env.BASE }} - name: Upload sdist uses: actions/upload-artifact@v4 with: diff --git a/ua-parser-py/Cargo.toml b/ua-parser-py/Cargo.toml index 76350c3..6a3c645 100644 --- a/ua-parser-py/Cargo.toml +++ b/ua-parser-py/Cargo.toml @@ -9,5 +9,5 @@ name = "ua_parser_rs" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.20.0", features = ["extension-module", "abi3", "abi3-py38"] } +pyo3 = { version = "0.22", features = ["extension-module", "abi3", "abi3-py38"] } ua-parser = { version = "0.2.0", path = "../ua-parser" } diff --git a/ua-parser-py/src/lib.rs b/ua-parser-py/src/lib.rs index 160c782..0951c58 100644 --- a/ua-parser-py/src/lib.rs +++ b/ua-parser-py/src/lib.rs @@ -1,5 +1,3 @@ -use pyo3::exceptions::PyValueError; -use pyo3::prelude::*; /// An uap-python Resolver is a callable which returns a PartialResult /// (~a triplet of optional user_agent, os, and domain). A resolver /// has lists of matchers for user agents, os, and devices taken in as @@ -27,6 +25,8 @@ use pyo3::prelude::*; /// them to Parsers as well but that's still very confusing given the /// global Parser object, unless *that* gets renamed to Extractor on /// the python side, or something. +use pyo3::exceptions::PyValueError; +use pyo3::prelude::*; use std::borrow::Cow::{self, Owned}; type UAParser = ( @@ -55,7 +55,7 @@ struct UserAgent { #[pymethods] impl UserAgentExtractor { #[new] - fn new(it: &PyAny) -> PyResult { + fn new(it: &Bound) -> PyResult { use ua_parser::user_agent::{Builder, Parser}; it.iter()? .try_fold(Builder::new(), |s, p| { @@ -111,7 +111,7 @@ struct OS { #[pymethods] impl OSExtractor { #[new] - fn new(it: &PyAny) -> PyResult { + fn new(it: &Bound) -> PyResult { use ua_parser::os::{Builder, Parser}; it.iter()? .try_fold(Builder::new(), |s, p| { @@ -162,7 +162,7 @@ struct Device { #[pymethods] impl DeviceExtractor { #[new] - fn new(it: &PyAny) -> PyResult { + fn new(it: &Bound) -> PyResult { use ua_parser::device::{Builder, Flag, Parser}; it.iter()? .try_fold(Builder::new(), |s, p| { @@ -194,7 +194,7 @@ impl DeviceExtractor { } #[pymodule] -fn ua_parser_rs(_py: Python, m: &PyModule) -> PyResult<()> { +fn ua_parser_rs(m: &Bound) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?;