Skip to content

Commit 883c936

Browse files
authored
Initial Rust implementation (#3)
Initial Rust implementation
1 parent 52adb74 commit 883c936

File tree

17 files changed

+4479
-628
lines changed

17 files changed

+4479
-628
lines changed

.github/workflows/build.yml

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,67 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: ["3.10", "3.11", "3.12", "3.13"]
13-
os: [ubuntu-latest, windows-latest, macos-latest]
12+
python-version: ["3.13"] # ["3.11", "3.12", "3.13"]
13+
os: [ubuntu-latest] # [ubuntu-latest, windows-latest, macos-latest]
1414

1515
runs-on: ${{ matrix.os }}
1616

1717
steps:
1818
- uses: actions/checkout@v4
1919

20+
- name: Cache Cargo dependencies
21+
uses: Swatinem/rust-cache@v2
22+
with:
23+
cache-all-crates: true
24+
cache-on-failure: true
25+
26+
- name: Set up Rust toolchain
27+
uses: actions-rs/toolchain@v1
28+
with:
29+
toolchain: stable
30+
31+
- name: Format + Clippy
32+
run: |
33+
cargo fmt --all -- --check
34+
cargo clippy -- -D warnings --allow dead_code
35+
2036
- name: Install uv
2137
uses: astral-sh/setup-uv@v4
22-
23-
- name: "Set up Python"
24-
uses: actions/setup-python@v5
2538
with:
26-
python-version-file: ".python-version"
39+
enable-cache: true
40+
cache-dependency-glob: "uv.lock"
2741

28-
- name: Restore uv cache
29-
uses: actions/cache@v4
42+
- name: Set up Python
43+
run: uv python install ${{ matrix.python-version }}
44+
45+
- name: Cache pip dependencies
46+
uses: actions/cache@v3
3047
with:
31-
path: /tmp/.uv-cache
32-
key: uv-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
48+
path: ~/.cache/pip
49+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt', '**/pyproject.toml', '**/setup.cfg') }}
3350
restore-keys: |
34-
uv-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}
35-
uv-${{ runner.os }}-py${{ matrix.python-version }}
36-
uv-${{ runner.os }}
51+
${{ runner.os }}-pip-
3752
38-
- name: Install dependencies
39-
run: uv sync --all-extras --dev
53+
- name: Install Python dependencies
54+
run: |
55+
uv sync --all-extras --dev
4056
4157
- name: Ruff
42-
run: uv run ruff check .
58+
run: uv run ruff check --select I .
59+
60+
- name: Build
61+
run: |
62+
pip install maturin[patchelf]
63+
maturin develop --uv --release
4364
44-
- name: MyPy
45-
run: uv run mypy .
65+
- name: Test
66+
run: |
67+
uv run pytest --durations=10
4668
47-
- name: Pytest
48-
run: uv run pytest
69+
- name: Benchmark
70+
run: |
71+
uv run benchmarks/book.py
72+
uv run benchmarks/order.py
4973
5074
- name: Minimize uv cache
5175
run: uv cache prune --ci

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Release 📦
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*" # Triggers workflow only when a tag matching this pattern is pushed
7+
8+
jobs:
9+
windows:
10+
runs-on: windows-latest
11+
strategy:
12+
matrix:
13+
python-version: ["3.10", "3.11", "3.12", "3.13"]
14+
target: [x86, x64]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions-rs/toolchain@v1
18+
with:
19+
profile: minimal
20+
toolchain: stable
21+
override: true
22+
23+
- if: matrix.python-version == '3.13'
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: 3.13
27+
architecture: ${{ matrix.target }}
28+
29+
- name: Build Wheels
30+
uses: PyO3/maturin-action@v1
31+
env:
32+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
33+
with:
34+
command: publish
35+
target: ${{ matrix.target }}
36+
args: -i ${{ matrix.python-version }} --no-sdist --skip-existing -m Cargo.toml
37+
38+
linux:
39+
runs-on: ubuntu-latest
40+
strategy:
41+
matrix:
42+
python-version: ["3.10", "3.11", "3.12", "3.13"]
43+
target: [x86_64, aarch64]
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: actions-rs/toolchain@v1
47+
with:
48+
profile: minimal
49+
toolchain: stable
50+
override: true
51+
52+
- name: Build Wheels
53+
uses: PyO3/maturin-action@v1
54+
env:
55+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
56+
with:
57+
command: publish
58+
target: ${{ matrix.target }}
59+
args: --no-default-features -i ${{ matrix.python-version }} --no-sdist --skip-existing -m Cargo.toml
60+
61+
macos:
62+
runs-on: macos-latest
63+
strategy:
64+
matrix:
65+
python-version: ["3.10", "3.11", "3.12", "3.13"]
66+
target: [x86_64, aarch64]
67+
steps:
68+
- uses: actions/checkout@v4
69+
- uses: actions-rs/toolchain@v1
70+
with:
71+
profile: minimal
72+
toolchain: stable
73+
override: true
74+
75+
- name: Build Wheels
76+
uses: PyO3/maturin-action@v1
77+
env:
78+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
79+
with:
80+
command: publish
81+
target: ${{ matrix.target }}
82+
args: -i ${{ matrix.python-version }} --no-sdist --skip-existing -m Cargo.toml

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)