diff --git a/.github/workflows/pyo3-wheels.yml b/.github/workflows/pyo3-wheels.yml index c40349e..9dc5558 100644 --- a/.github/workflows/pyo3-wheels.yml +++ b/.github/workflows/pyo3-wheels.yml @@ -18,51 +18,51 @@ 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 }} + runs-on: ubuntu-latest strategy: matrix: + python-version: + - "3.x" + - "pypy-3.10" + - "graalpy" platform: - - runner: ubuntu-latest - target: x86_64 - - runner: ubuntu-latest - target: x86 - - runner: ubuntu-latest - target: aarch64 - - runner: ubuntu-latest - target: armv7 + - target: x86_64 + #- target: x86 + - target: aarch64 + #- target: armv7 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.x + python-version: ${{ python-version }} - name: Build wheels 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 uses: actions/upload-artifact@v4 with: - name: wheels-linux-${{ matrix.platform.target }} - path: dist + name: wheels-linux-${{ matrix.platform.target }}-${{ matrix.python-version }} + path: dist/* musllinux: - runs-on: ${{ matrix.platform.runner }} + runs-on: ubuntu-latest strategy: matrix: platform: - - runner: ubuntu-latest - target: x86_64 - - runner: ubuntu-latest - target: x86 - - runner: ubuntu-latest - target: aarch64 - - runner: ubuntu-latest - target: armv7 + - target: x86_64 + # - target: x86 + - target: aarch64 + #- target: armv7 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -72,7 +72,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 @@ -82,14 +82,11 @@ jobs: path: dist windows: - runs-on: ${{ matrix.platform.runner }} + runs-on: windows-latest strategy: matrix: platform: - - runner: windows-latest - target: x64 - - runner: windows-latest - target: x86 + - target: x64 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -100,7 +97,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 @@ -109,14 +106,12 @@ jobs: path: dist macos: - runs-on: ${{ matrix.platform.runner }} + runs-on: macos-14 strategy: matrix: platform: - - runner: macos-12 - target: x86_64 - - runner: macos-14 - target: aarch64 + - target: x86_64 + - target: aarch64 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -126,7 +121,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 +137,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/.github/workflows/pytests.yaml b/.github/workflows/pytests.yaml index a2eaf32..8d6ad79 100644 --- a/.github/workflows/pytests.yaml +++ b/.github/workflows/pytests.yaml @@ -16,14 +16,11 @@ jobs: fail-fast: false matrix: python-version: - - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" - "3.13" - - "pypy-3.8" - - "pypy-3.9" - "pypy-3.10" - "graalpy-24" steps: 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::()?; diff --git a/ua-parser-py/tox.ini b/ua-parser-py/tox.ini index dc38718..ad09f15 100644 --- a/ua-parser-py/tox.ini +++ b/ua-parser-py/tox.ini @@ -1,5 +1,5 @@ [tox] -env_list = py{38,39,310,311,312}, pypy3.{9,10}#, graalpy +env_list = py{39,310,311,312}, pypy3.10#, graalpy , typecheck, format, lint skip_missing_interpreters = true