Skip to content

Commit

Permalink
Add prebuilt binaries for Python 3.13 (#27)
Browse files Browse the repository at this point in the history
* Hopefully add prebuilt binaries for Python 3.13

* Setup mypy and bump minimal python version to 3.9

* fix

* Setup MSRV

* cleanup

* clippy and MSRV

* version bump

* Explicit version range on setup-python action
  • Loading branch information
AngheloAlf authored Dec 16, 2024
1 parent 482b9ba commit 4723fc6
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 28 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/maturin_upload_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.9 - 3.13'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand All @@ -50,7 +50,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.13'
architecture: ${{ matrix.target }}
- name: Build wheels
uses: PyO3/maturin-action@v1
Expand All @@ -76,7 +76,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.13'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
Expand Down Expand Up @@ -113,6 +113,26 @@ jobs:
path: dist
if-no-files-found: error

check_clippy_python_bindings:
name: Check clippy for Python bindings
runs-on: ubuntu-latest

steps:
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Setup clippy
run: rustup component add clippy

- name: Run clippy
run: cargo clippy --all-targets --features python_bindings -- -D warnings

release:
name: Release
runs-on: ubuntu-latest
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check mypy

# Build on every branch push, tag push, and pull request change:
on: [push, pull_request]

jobs:
checks:
runs-on: ubuntu-latest
name: mypy
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install Dependencies
run: |
python3 -m pip install -U mypy
- name: mypy
run: |
python3 -m mypy --show-column-numbers --hide-error-context .
33 changes: 30 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@ env:
CARGO_TERM_COLOR: always

jobs:
rustfmt-check:
rustfmt:
name: Check formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Run cargo fmt
run: cargo fmt --all -- --check

clippy:
name: Check clippy
runs-on: ubuntu-latest
steps:
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Run cargo clippy
run: cargo clippy --all -- -D warnings
run: |
cargo clippy --version
cargo clippy --all --all-targets --all-features -- -D warnings
macos-check:
runs-on: macos-latest
Expand All @@ -35,3 +48,17 @@ jobs:
- uses: actions/checkout@v4
- name: Test
run: cargo test

msrv:
name: Check MSRV
runs-on: ubuntu-latest
steps:
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Setup MSRV checker
uses: taiki-e/install-action@cargo-hack

# To find current MSRV use `cargo msrv find`. Install it with `cargo install cargo-msrv --locked`
- name: Run MSRV checker
run: cargo hack check --rust-version --workspace --all-targets --ignore-private
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.2] - 2024-12-15

### Added

- Prebuilt binaries for Python 3.13.
- Check Python files with mypy.
- Set MSRV (minimum supported Rust version) to 1.73.

### Changed

- Python 3.9 or later is now required.
- Mainly due to not being able to automatically check and build for older versions in CI.

## [0.5.1] - 2024-07-25

### Fixed
Expand Down Expand Up @@ -73,6 +86,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- C bindings.

[unreleased]: https://github.com/decompals/crunch64/compare/0.5.1...HEAD
[0.5.2]: https://github.com/decompals/crunch64/compare/0.5.1...0.5.2
[0.5.1]: https://github.com/decompals/crunch64/compare/0.5.0...0.5.1
[0.5.0]: https://github.com/decompals/crunch64/compare/0.4.0...0.5.0
[0.4.0]: https://github.com/decompals/crunch64/compare/0.3.1...0.4.0
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[package]
name = "crunch64-cli"
version = "0.5.1"
version = "0.5.2"
edition = "2021"
description = "A utility for compressing/decompressing files with common n64 formats"
repository = "https://github.com/decompals/crunch64"
license = "MIT"
rust-version = "1.73.0"

[[bin]]
name = "crunch64"
path = "src/main.rs"

[dependencies]
crunch64 = { version = "0.5.1", path = "../lib" }
crunch64 = { version = "0.5.2", path = "../lib" }
clap = { version = "4.4.11", features = ["derive"] }
3 changes: 2 additions & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[package]
name = "crunch64"
# Version should be synced with lib/pyproject.toml and lib/crunch64/__init__.py
version = "0.5.1"
version = "0.5.2"
edition = "2021"
description = "A library for handling common compression formats for N64 games"
repository = "https://github.com/decompals/crunch64"
license = "MIT"
rust-version = "1.73.0"

[lib]
name = "crunch64"
Expand Down
2 changes: 1 addition & 1 deletion lib/crunch64/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

# Version should be synced with lib/Cargo.toml and lib/pyproject.toml
__version_info__ = (0, 5, 1)
__version_info__ = (0, 5, 2)
__version__ = ".".join(map(str, __version_info__))
__author__ = "decompals"

Expand Down
2 changes: 1 addition & 1 deletion lib/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "crunch64"
# Version should be synced with lib/Cargo.toml and lib/crunch64/__init__.py
version = "0.5.1"
description = "A library for handling common compression formats for N64 games"
requires-python = ">=3.7"
requires-python = ">=3.9"
dependencies = [
]
classifiers = [
Expand Down
6 changes: 1 addition & 5 deletions lib/src/mio0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,9 @@ pub fn decompress(bytes: &[u8]) -> Result<Box<[u8]>, Crunch64Error> {
Ok(ret.into_boxed_slice())
}

fn divide_round_up(a: usize, b: usize) -> usize {
(a + b - 1) / b
}

fn size_for_compressed_buffer(input_size: usize) -> Result<usize, Crunch64Error> {
// Taken from Yaz0
Ok(input_size + divide_round_up(input_size, 8) + 0x10)
Ok(input_size + input_size.div_ceil(8) + 0x10)
}

pub fn compress(bytes: &[u8]) -> Result<Box<[u8]>, Crunch64Error> {
Expand Down
6 changes: 1 addition & 5 deletions lib/src/yay0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,9 @@ pub fn decompress(bytes: &[u8]) -> Result<Box<[u8]>, Crunch64Error> {
Ok(ret.into_boxed_slice())
}

fn divide_round_up(a: usize, b: usize) -> usize {
(a + b - 1) / b
}

fn size_for_compressed_buffer(input_size: usize) -> Result<usize, Crunch64Error> {
// Taken from Yaz0
Ok(input_size + divide_round_up(input_size, 8) + 0x10)
Ok(input_size + input_size.div_ceil(8) + 0x10)
}

pub fn compress(bytes: &[u8]) -> Result<Box<[u8]>, Crunch64Error> {
Expand Down
6 changes: 1 addition & 5 deletions lib/src/yaz0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,11 @@ pub fn decompress(bytes: &[u8]) -> Result<Box<[u8]>, Crunch64Error> {
Ok(ret.into_boxed_slice())
}

fn divide_round_up(a: usize, b: usize) -> usize {
(a + b - 1) / b
}

fn size_for_compressed_buffer(input_size: usize) -> Result<usize, Crunch64Error> {
// Worst-case size for output is zero compression on the input, meaning the input size plus the number of layout bytes plus the Yaz0 header.
// There would be one layout byte for every 8 input bytes, so the worst-case size is:
// input_size + ROUND_UP_DIVIDE(input_size, 8) + 0x10
Ok(input_size + divide_round_up(input_size, 8) + 0x10)
Ok(input_size + input_size.div_ceil(8) + 0x10)
}

pub fn compress(bytes: &[u8]) -> Result<Box<[u8]>, Crunch64Error> {
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
python_version = 3.9
check_untyped_defs = True

0 comments on commit 4723fc6

Please sign in to comment.