Skip to content

Commit b2571d4

Browse files
committed
Bump pyo3 version and get to some of the comments
1 parent 9036d3a commit b2571d4

File tree

8 files changed

+77
-52
lines changed

8 files changed

+77
-52
lines changed

.github/workflows/python_bindings.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,36 @@ on: [push, pull_request]
55

66
jobs:
77
tests_cases:
8-
name: Tests cases
8+
name: Tests for Python ${{ matrix.py_version}}
99
runs-on: ubuntu-latest
1010
strategy:
1111
fail-fast: false
12+
matrix:
13+
py_version:
14+
- '3.8'
15+
- '3.9'
16+
- '3.10'
17+
- '3.11'
18+
- '3.12'
19+
- '3.13'
20+
- '3.14'
21+
- '3.x' # Explicit latest
1222

1323
steps:
14-
- name: Checkout repo
15-
uses: actions/checkout@v5
24+
- name: Checkout repo
25+
uses: actions/checkout@v5
1626

17-
- name: Setup requirements
18-
run: |
19-
python3 -m pip install -U maturin
27+
- name: Setup Python ${{ matrix.py_version }}
28+
uses: actions/setup-python@v6
29+
with:
30+
python-version: ${{ matrix.py_version }}
2031

21-
- name: Install local pigment64
22-
run: python3 -m pip install .
32+
- name: Setup requirements
33+
run: |
34+
python3 --version
35+
python3 -m pip install -U maturin
36+
- name: Install local pigment64
37+
run: python3 -m pip install ./lib
2338

24-
- name: Run tests
25-
run: python3 ./tests/test_python.py
39+
- name: Run tests
40+
run: python3 ./python_bindings/tests.py

.github/workflows/release.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
on:
22
release:
33
types: [created]
4+
45
jobs:
56
release:
67
name: release ${{ matrix.target }}
@@ -12,23 +13,24 @@ jobs:
1213
- target: x86_64-pc-windows-gnu
1314
- target: x86_64-unknown-linux-musl
1415
- target: x86_64-apple-darwin
16+
1517
steps:
16-
- uses: actions/checkout@master
18+
- name: Checkout repo
19+
uses: actions/checkout@5
20+
1721
- name: Compile and release
1822
uses: rust-build/rust-build.action@v1.4.5
1923
env:
2024
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2125
with:
2226
RUSTTARGET: ${{ matrix.target }}
2327
ARCHIVE_TYPES: tar.gz
28+
2429
publish:
2530
runs-on: ubuntu-latest
2631
steps:
27-
- uses: actions/checkout@v3
28-
- uses: actions-rs/toolchain@v1
29-
with:
30-
toolchain: stable
31-
override: true
32+
- uses: actions/checkout@v5
33+
- uses: dtolnay/rust-toolchain@stable
3234
- uses: katyo/publish-crates@v2
3335
with:
3436
registry-token: ${{ secrets.CRATE_AUTH_TOKEN }}

.github/workflows/rust.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,45 @@ env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13-
rustfmt-check:
13+
rustfmt:
14+
name: Check formatting
1415
runs-on: ubuntu-latest
1516
steps:
16-
- uses: actions/checkout@v5
17+
- name: Checkout reposistory
18+
uses: actions/checkout@v5
19+
1720
- name: Run cargo fmt
1821
run: cargo fmt --all -- --check
22+
23+
clippy:
24+
name: Check clippy
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout reposistory
28+
uses: actions/checkout@v5
29+
1930
- name: Run cargo clippy
20-
run: cargo clippy --all -- -D warnings
31+
run: |
32+
cargo clippy --version
33+
cargo clippy --all --all-targets --all-features -- -D warnings
34+
2135
macos-check:
2236
runs-on: macos-latest
2337
steps:
2438
- uses: actions/checkout@v5
25-
# Set up a Python environment for the linker to the right Python libraries
26-
- name: Set up Python
27-
uses: actions/setup-python@v5
28-
with:
29-
python-version: '3.10'
3039
- name: Test
31-
run: cargo test --all-features
40+
run: cargo test
41+
3242
ubuntu-check:
3343
runs-on: ubuntu-latest
3444
steps:
3545
- uses: actions/checkout@v5
3646
- name: Test
37-
run: cargo test --all-features
47+
run: cargo test
48+
3849
windows-check:
3950
runs-on: windows-latest
4051
steps:
4152
- uses: actions/checkout@v5
4253
- name: Test
43-
run: cargo test --all-features
54+
run: cargo test

Cargo.lock

Lines changed: 10 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ crate-type = ["cdylib", "rlib"]
1818
name = "pigment64_cli"
1919
path = "src/main.rs"
2020

21+
[features]
22+
python_bindings = ["dep:pyo3"]
23+
2124
[dependencies]
2225
png = "0.17.16"
2326
clap = { version = "4.5.45", features = ["derive"] }
@@ -29,7 +32,4 @@ strum_macros = "0.27.2"
2932
thiserror = "2.0.15"
3033

3134
# Python bindings
32-
pyo3 = { version="0.25", features = ["extension-module"], optional = true }
33-
34-
[features]
35-
python_bindings = ["dep:pyo3"]
35+
pyo3 = { version="0.26", features = ["extension-module"], optional = true }

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ This project uses `maturin` to build the Rust-based Python extension. It is reco
4949

5050
#### Setup
5151

52-
1. **Create and activate a virtual environment:**
52+
1. Create and activate a virtual environment:
5353
```bash
5454
python3 -m venv .venv
5555
source .venv/bin/activate
5656
```
5757

58-
2. **Install dependencies:**
58+
2. Install dependencies:
5959
```bash
6060
pip install maturin pytest
6161
```
@@ -65,7 +65,7 @@ This project uses `maturin` to build the Rust-based Python extension. It is reco
6565
To compile the library and install it into your active virtual environment, run:
6666

6767
```bash
68-
maturin develop --features python_bindings
68+
maturin develop
6969
```
7070
## License
7171

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "pigment64"
33
# Version should be synced with lib/Cargo.toml and lib/pigment64/__init__.py
4-
version = "0.5.3"
4+
version = "0.6.0"
55
description = "A library for handling conversion between N64 texture formats and modern image formats"
66
requires-python = ">=3.9"
77
dependencies = [

src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ use num_enum::TryFromPrimitive;
99
use strum_macros::{EnumCount, EnumIter};
1010
use thiserror::Error;
1111

12-
// PyO3 imports (will only be used if the feature is enabled)
12+
// Conditional imports for Python bindings
1313
#[cfg(feature = "python_bindings")]
14-
use pyo3::prelude::*;
14+
use pyo3::{Bound, prelude::*, types::PyBytes};
1515
#[cfg(feature = "python_bindings")]
16-
use pyo3::types::PyBytes;
17-
#[cfg_attr(not(feature = "python_bindings"), allow(unused_imports))]
1816
use std::io::Cursor;
1917

2018
#[derive(Debug, Error)]
@@ -194,14 +192,14 @@ impl PyPNGImage {
194192
fn as_i8(&self) -> PyResult<Py<PyBytes>> {
195193
let mut buf = Vec::new();
196194
self.img.as_i8(&mut buf)?;
197-
let py = unsafe { Python::assume_gil_acquired() };
195+
let py = unsafe { Python::assume_attached() };
198196
Ok(PyBytes::new(py, &buf).into())
199197
}
200198

201199
fn as_rgba16(&self) -> PyResult<Py<PyBytes>> {
202200
let mut buf = Vec::new();
203201
self.img.as_rgba16(&mut buf)?;
204-
let py = unsafe { Python::assume_gil_acquired() };
202+
let py = unsafe { Python::assume_attached() };
205203
Ok(PyBytes::new(py, &buf).into())
206204
}
207205
}

0 commit comments

Comments
 (0)