Repository navigation
114 lines (109 loc) · 3.83 KB
/
Copy pathpython.yml
File metadata and controls
114 lines (109 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Python
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
workflow_call:
permissions:
contents: read
jobs:
check:
name: Rust checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v10.3.3
with:
python-version: '3.11'
activate-environment: true
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Check tag matches package version
if: startsWith(github.ref, 'refs/tags/')
run: |
python -c "import os, tomllib; version = tomllib.load(open('Cargo.toml', 'rb'))['package']['version']; assert os.environ['GITHUB_REF_NAME'] == f'v{version}', 'tag must match Cargo.toml version'"
- run: cargo fmt --check
- run: cargo clippy --locked --all-targets -- -D warnings
- name: Rust tests
run: |
PYTHONHOME="$(python -c 'import sys; print(sys.base_prefix)')"
export PYTHONHOME
LD_LIBRARY_PATH="$PYTHONHOME/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" cargo test --locked --lib
wheels:
name: Wheel (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v10.3.3
with:
python-version: '3.11'
activate-environment: true
- uses: PyO3/maturin-action@v1.51.0
with:
maturin-version: v1.16.0
rust-toolchain: stable
target: ${{ matrix.target }}
manylinux: '2014'
args: --release --locked --out dist --compatibility pypi --interpreter ${{ runner.os == 'Linux' && 'python3.11' || 'python' }}
- name: Test wheel on Python 3.11
run: |
uv run --active --no-sync python -c "import sys; assert sys.version_info[:2] == (3, 11), sys.version"
uv pip install --no-deps --no-index --find-links dist boko-ebook
uv run --active --no-sync python -m unittest discover -s tests -v
- uses: astral-sh/setup-uv@v10.3.3
with:
python-version: '3.15'
activate-environment: true
venv-path: ${{ runner.temp }}/python315
- name: Test wheel on Python 3.15
run: |
uv run --active --no-sync python -c "import sys; assert sys.version_info[:2] == (3, 15), sys.version"
uv pip install --no-deps --no-index --find-links dist boko-ebook
uv run --active --no-sync python -m unittest discover -s tests -v
- uses: actions/upload-artifact@v7.0.2
with:
name: wheels-${{ matrix.target }}
path: dist/*.whl
if-no-files-found: error
sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v10.3.3
with:
python-version: '3.11'
activate-environment: true
- uses: dtolnay/rust-toolchain@stable
- run: uv build --sdist
- name: Rebuild and test source distribution
run: |
uv pip install --no-deps dist/*.tar.gz
uv run --active --no-sync python -m unittest discover -s tests -v
- uses: actions/upload-artifact@v7.0.2
with:
name: sdist
path: dist/*.tar.gz
if-no-files-found: error