-
Notifications
You must be signed in to change notification settings - Fork 422
Expand file tree
/
Copy pathbuild-python-release.reusable.yaml
More file actions
178 lines (156 loc) · 6.36 KB
/
build-python-release.reusable.yaml
File metadata and controls
178 lines (156 loc) · 6.36 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
168
169
170
171
172
173
174
175
176
177
178
name: BAML Release - Build Python
on:
workflow_call: {}
push:
branches:
- sam/license-fix
concurrency:
# suffix is important to prevent a concurrency deadlock with the calling workflow
group: ${{ github.workflow }}-${{ github.ref }}-build-python
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
build:
strategy:
fail-fast: false
matrix:
_:
- target: x86_64-unknown-linux-gnu
runs_on: ubuntu-latest
manylinux: 2_17
- target: aarch64-unknown-linux-gnu
runs_on: ubuntu-latest
manylinux: 2_24
# I'm not sure if this actually works; I can't 'pip install ./local-path.whl'
# from inside a container based off quay.io/pypa/manylinux2014_aarch64
# see https://github.com/astral-sh/uv/issues/3439#issuecomment-2110448346
# manylinux: 2_28
# env:
# # Workaround ring 0.17 build issue
# # see https://github.com/briansmith/ring/issues/1728
# CFLAGS_aarch64_unknown_linux_gnu: "-D__ARM_ARCH=8"
license_test: skip
- target: x86_64-unknown-linux-musl
runs_on: ubuntu-latest
# see https://github.com/astral-sh/uv/blob/9bb55c4ac0582e05d1a7a5bbd99cc7b2c82f1847/.github/workflows/build-binaries.yml#L594
manylinux: musllinux_1_1
license_test: skip
- target: aarch64-unknown-linux-musl
runs_on: ubuntu-latest
# see https://github.com/astral-sh/uv/blob/9bb55c4ac0582e05d1a7a5bbd99cc7b2c82f1847/.github/workflows/build-binaries.yml#L594
manylinux: musllinux_1_1
license_test: skip
- target: x86_64-apple-darwin
runs_on: macos-latest
license_test: skip
- target: aarch64-apple-darwin
runs_on: macos-latest
- target: x86_64-pc-windows-msvc
runs_on: windows-latest
- target: aarch64-pc-windows-msvc
runs_on: windows-11-arm
architecture: arm64
name: ${{ matrix._.target }}
runs-on: ${{ matrix._.runs_on }}
# See also https://github.com/mcrumiller/polars/.github/workflows/release-python.yml#L282
steps:
- name: Setup build environment (ARM64 Windows)
if: matrix._.target == 'aarch64-pc-windows-msvc'
shell:
powershell
# Notes
# * We update `Expand-Archive` to avoid "" is not a supported archive file format when extracting
# files that don't end in `.zip`
run: |
# rustup is not installed in aarch64
if (-not (Get-Command rustup -ErrorAction SilentlyContinue)) {
Invoke-WebRequest -Uri "https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe" -OutFile "rustup-init.exe"
.\rustup-init.exe --default-toolchain stable -y
Remove-Item "rustup-init.exe"
"$env:USERPROFILE/.cargo/bin" | Out-File -FilePath "$env:GITHUB_PATH" -Append
}
- name: Check build environment (ARM64 Windows)
if: matrix._.target == 'aarch64-pc-windows-msvc'
run: |
set -x
bash --version
rustup show
clang -v
cmake --version
- uses: actions/checkout@v6
# Setup Python for non-ARM64 Windows targets and other OS
- name: Setup Python (default)
if: matrix._.target != 'aarch64-pc-windows-msvc'
uses: actions/setup-python@v6
with:
python-version: "3.8"
architecture: ${{ matrix._.architecture }}
# Setup Python versions for ARM64 Windows
- name: Setup Python 3.11 (ARM64 Windows)
if: matrix._.target == 'aarch64-pc-windows-msvc'
uses: actions/setup-python@v6
id: py311
with:
python-version: "3.11"
architecture: "arm64"
allow-prereleases: true
- name: Setup Python 3.12 (ARM64 Windows)
if: matrix._.target == 'aarch64-pc-windows-msvc'
uses: actions/setup-python@v6
id: py312
with:
python-version: "3.12"
architecture: "arm64"
allow-prereleases: true
- name: Setup Python 3.13 (ARM64 Windows)
if: matrix._.target == 'aarch64-pc-windows-msvc'
uses: actions/setup-python@v6
id: py313
with:
python-version: "3.13"
architecture: "arm64"
allow-prereleases: true
- name: Build wheels
uses: PyO3/maturin-action@v1
env:
# see https://github.com/PyO3/maturin/issues/2110
XWIN_VERSION: "16"
with:
target: ${{ matrix._.target }}
command: build
# building in engine/ ensures that we pick up .cargo/config.toml
working-directory: engine
args: --release --out language_client_python/dist --manifest-path language_client_python/Cargo.toml ${{ (matrix._.target == 'aarch64-pc-windows-msvc' && format('--interpreter {0} {1} {2}', steps.py311.outputs.python-path, steps.py312.outputs.python-path, steps.py313.outputs.python-path)) || '' }}
manylinux: ${{ matrix._.manylinux }}
before-script-linux: |
if command -v yum &> /dev/null; then
yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic
else
# If we're running on debian-based system.
# sudo apt update -y && apt-get install -y libssl-dev openssl pkg-config
:
fi
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
- name: Test LICENSE packaging
if: matrix._.license_test != 'skip'
run: |
set -euo pipefail
mkdir -p ../python-license-test
cd ../python-license-test
uv init --bare --python 3.10
uv add pip-licenses-cli
pwd
ls ../baml/engine/language_client_python/dist/
uv pip install $(ls ../baml/engine/language_client_python/dist/*.whl)
uv run pip-licenses | tee license-audit.log
# Due to `set -e`, this will fail if no matches are found
grep 'baml.*Apache-2.0' license-audit.log >/dev/null
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-${{ matrix._.target }}
path: engine/language_client_python/dist
if-no-files-found: error