-
-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (143 loc) · 5.29 KB
/
python.yml
File metadata and controls
167 lines (143 loc) · 5.29 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Python CI
on:
push:
branches: ["github"]
pull_request:
branches: ["github"]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Python tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- name: Install Linux build deps
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang lld cmake pkg-config libseccomp-dev
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Create Python test venv
shell: bash
run: |
uv venv .venv
- name: Install Python test tools
shell: bash
env:
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
run: |
uv pip install --python "$VENV_PY" "maturin>=1.7,<2" "pytest>=8.0" "pytest-cov>=7.0.0"
- name: Build extension (Linux)
if: runner.os == 'Linux'
shell: bash
env:
VIRTUAL_ENV: .venv
VENV_PY: .venv/bin/python
CC: clang
CXX: clang++
RUSTFLAGS: -C link-arg=-fuse-ld=lld -C target-cpu=x86-64
run: |
export PATH="$(dirname "$VENV_PY"):$PATH"
"$VENV_PY" -m maturin develop --profile python-release --manifest-path infotheory_py/Cargo.toml
- name: Build extension (macOS/Windows)
if: runner.os != 'Linux'
shell: bash
env:
VIRTUAL_ENV: .venv
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
run: |
export PATH="$(dirname "$VENV_PY"):$PATH"
"$VENV_PY" -m maturin develop --profile python-release --manifest-path infotheory_py/Cargo.toml
- name: Run tests
shell: bash
env:
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
run: |
"$VENV_PY" -m pytest --cov=infotheory_rs --cov-report=term-missing --cov-report=xml:target/python-coverage.xml --cov-fail-under=100 python/tests
- name: Upload Python coverage artifact
uses: actions/upload-artifact@v4
with:
name: python-coverage-${{ matrix.os }}
path: target/python-coverage.xml
if-no-files-found: error
- name: Build sdist
shell: bash
env:
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
run: |
"$VENV_PY" -m maturin sdist --manifest-path infotheory_py/Cargo.toml
- name: Build wheel (Linux)
if: runner.os == 'Linux'
shell: bash
env:
VENV_PY: .venv/bin/python
CC: clang
CXX: clang++
RUSTFLAGS: -C link-arg=-fuse-ld=lld -C target-cpu=x86-64
run: |
export PATH="$(dirname "$VENV_PY"):$PATH"
"$VENV_PY" -m maturin build --profile python-release --manifest-path infotheory_py/Cargo.toml
- name: Build wheel (macOS/Windows)
if: runner.os != 'Linux'
shell: bash
env:
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
run: |
export PATH="$(dirname "$VENV_PY"):$PATH"
"$VENV_PY" -m maturin build --profile python-release --manifest-path infotheory_py/Cargo.toml
- name: Install built wheel and import
shell: bash
env:
WHEEL_VENV_PY: ${{ runner.os == 'Windows' && '.wheel-venv/Scripts/python.exe' || '.wheel-venv/bin/python' }}
run: |
set -euo pipefail
uv venv .wheel-venv
wheel="$(ls target/wheels/*.whl | head -n1)"
uv pip install --python "$WHEEL_VENV_PY" "$wheel"
"$WHEEL_VENV_PY" -c "import infotheory_rs; print('ok')"
test-vm-linux:
name: Python VM smoke (Linux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@stable
- name: Install Linux build deps
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang lld cmake pkg-config libseccomp-dev
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Create Python VM venv
shell: bash
run: |
uv venv .venv
- name: Install Python VM test tools
shell: bash
run: |
uv pip install --python .venv/bin/python "maturin>=1.7,<2" "pytest>=8.0"
- name: Build extension with VM feature
shell: bash
env:
VIRTUAL_ENV: .venv
CC: clang
CXX: clang++
RUSTFLAGS: -C link-arg=-fuse-ld=lld -C target-cpu=x86-64
run: |
export PATH=".venv/bin:$PATH"
.venv/bin/python -m maturin develop --profile python-release --manifest-path infotheory_py/Cargo.toml --features python-extension,backend-rosa,backend-mamba,backend-rwkv,backend-zpaq,vm
- name: Run VM-featured Python smoke tests
shell: bash
run: |
.venv/bin/python -m pytest -q python/tests/test_vm.py