-
-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (122 loc) · 4.2 KB
/
Copy pathpython-release.yml
File metadata and controls
140 lines (122 loc) · 4.2 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
name: Python Wheels
on:
push:
tags: ["v*"]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
PYTHON_RELEASE_FEATURES: python-extension,all-backends,aixi-gameengine
permissions:
contents: read
jobs:
build:
name: Build wheels (${{ 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
- uses: astral-sh/setup-uv@v4
- name: Create Python release venv
shell: bash
run: |
uv venv .venv
- name: Install Linux build deps
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang lld
- name: Install Python release tools (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
uv pip install --python .venv/bin/python "maturin[zig]>=1.7,<2"
- name: Install Python release tools (macOS/Windows)
if: runner.os != 'Linux'
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"
- name: Validate Linux release cargo env overrides
if: runner.os == 'Linux'
env:
RUSTFLAGS: -C target-cpu=x86-64
run: >-
cargo check --release --manifest-path crates/infotheory_py/Cargo.toml
--features $PYTHON_RELEASE_FEATURES
- name: Build wheel (Linux)
if: runner.os == 'Linux'
shell: bash
env:
CC: clang
CXX: clang++
ZPAQ_RS_CXX: clang++
RUSTFLAGS: -C target-cpu=x86-64
run: |
export PATH=".venv/bin:$PATH"
rm -rf target/maturin-linux
ln -sf python-zig .venv/bin/zig
export ZIG_COMMAND="$(command -v zig)"
export AR_x86_64_unknown_linux_gnu="$(command -v llvm-ar)"
export RANLIB_x86_64_unknown_linux_gnu="$(command -v llvm-ranlib)"
.venv/bin/python -m maturin build --release \
--manifest-path crates/infotheory_py/Cargo.toml \
--target-dir target/maturin-linux \
--interpreter python3 \
--features "$PYTHON_RELEASE_FEATURES" \
--out target/wheels \
--compatibility manylinux2014 \
--zig
- name: Build wheel (macOS/Windows)
if: runner.os != 'Linux'
shell: bash
env:
VENV_PY: ${{ runner.os == 'Windows' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
RUSTFLAGS: -C target-cpu=generic
run: |
export PATH="$(dirname "$VENV_PY"):$PATH"
rm -rf "target/maturin-${{ runner.os }}"
"$VENV_PY" -m maturin build --release --manifest-path crates/infotheory_py/Cargo.toml --target-dir "target/maturin-${{ runner.os }}" --features "$PYTHON_RELEASE_FEATURES" --out target/wheels
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: python-wheels-${{ matrix.os }}
path: target/wheels/*
if-no-files-found: error
- name: Build sdist (Linux only)
if: runner.os == 'Linux'
shell: bash
run: |
export PATH=".venv/bin:$PATH"
.venv/bin/python -m maturin sdist --manifest-path crates/infotheory_py/Cargo.toml
- name: Upload sdist artifact
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: python-sdist
path: target/wheels/*.tar.gz
if-no-files-found: error
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
steps:
- name: Download wheel/sdist artifacts
uses: actions/download-artifact@v4
with:
pattern: python-*
path: dist
merge-multiple: true
- name: Publish distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist