-
Notifications
You must be signed in to change notification settings - Fork 3
191 lines (164 loc) · 5.49 KB
/
build-python-wheels.yml
File metadata and controls
191 lines (164 loc) · 5.49 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
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Build Python Wheels
on:
workflow_call:
inputs:
upload-artifacts:
description: 'Upload wheel artifacts'
required: false
default: true
type: boolean
test-wheels:
description: 'Test the built wheels'
required: false
default: true
type: boolean
jobs:
build-wheels:
name: Build wheel (${{ matrix.platform }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS Apple Silicon
- os: macos-14
platform: darwin-aarch64
wheel_platform: macosx_14_0_arm64
rust_target: aarch64-apple-darwin
# macOS Intel
- os: macos-15-intel
platform: darwin-x86_64
wheel_platform: macosx_15_0_x86_64
rust_target: x86_64-apple-darwin
# Linux x86_64 glibc
- os: ubuntu-22.04
platform: linux-x86_64-gnu
wheel_platform: manylinux_2_35_x86_64
rust_target: x86_64-unknown-linux-gnu
# Linux ARM64 glibc
- os: ubuntu-22.04-arm
platform: linux-aarch64-gnu
wheel_platform: manylinux_2_35_aarch64
rust_target: aarch64-unknown-linux-gnu
# Windows x64
- os: windows-latest
platform: windows-x86_64
wheel_platform: win_amd64
rust_target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}
- name: Build pg0 CLI (Unix)
if: runner.os != 'Windows'
env:
BUNDLE_POSTGRESQL: "true"
run: |
cargo build --release --target ${{ matrix.rust_target }}
ls -la target/${{ matrix.rust_target }}/release/pg0*
- name: Build pg0 CLI (Windows)
if: runner.os == 'Windows'
env:
BUNDLE_POSTGRESQL: "true"
run: |
cargo build --release --target ${{ matrix.rust_target }}
dir target\${{ matrix.rust_target }}\release\pg0*
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build wheel (Unix)
if: runner.os != 'Windows'
working-directory: sdk/python
env:
PG0_BINARY_PATH: ${{ github.workspace }}/target/${{ matrix.rust_target }}/release/pg0
run: uv build --wheel
- name: Build wheel (Windows)
if: runner.os == 'Windows'
working-directory: sdk/python
env:
PG0_BINARY_PATH: ${{ github.workspace }}\target\${{ matrix.rust_target }}\release\pg0.exe
run: uv build --wheel
- name: Rename wheel to platform-specific
working-directory: sdk/python/dist
run: |
for f in *.whl; do
newname=$(echo "$f" | sed 's/py3-none-any/py3-none-${{ matrix.wheel_platform }}/g')
if [ "$f" != "$newname" ]; then
echo "Renaming $f -> $newname"
mv "$f" "$newname"
fi
done
ls -la
shell: bash
- name: Test wheel (Unix)
if: inputs.test-wheels && runner.os != 'Windows'
working-directory: sdk/python
run: |
uv venv test-env
source test-env/bin/activate
pip install dist/*.whl
python -c "
from pg0 import _get_bundled_binary, Pg0
bundled = _get_bundled_binary()
assert bundled is not None, 'Bundled binary not found!'
assert bundled.exists(), f'Bundled binary does not exist: {bundled}'
print(f'Bundled binary found: {bundled}')
pg = Pg0(name='wheel-test')
info = pg.start()
print(f'Started PostgreSQL: {info.uri}')
pg.stop()
pg.drop()
print('Wheel test passed!')
"
- name: Test wheel (Windows)
if: inputs.test-wheels && runner.os == 'Windows'
working-directory: sdk/python
run: |
uv venv test-env
test-env\Scripts\activate
pip install (Get-ChildItem dist\*.whl).FullName
python -c "
from pg0 import _get_bundled_binary, Pg0
bundled = _get_bundled_binary()
assert bundled is not None, 'Bundled binary not found!'
assert bundled.exists(), f'Bundled binary does not exist: {bundled}'
print(f'Bundled binary found: {bundled}')
pg = Pg0(name='wheel-test')
info = pg.start()
print(f'Started PostgreSQL: {info.uri}')
pg.stop()
pg.drop()
print('Wheel test passed!')
"
shell: pwsh
- name: Upload wheel artifact
if: inputs.upload-artifacts
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.platform }}
path: sdk/python/dist/*.whl
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Build sdist
working-directory: sdk/python
run: uv build --sdist
- name: Upload sdist artifact
if: inputs.upload-artifacts
uses: actions/upload-artifact@v4
with:
name: sdist
path: sdk/python/dist/*.tar.gz