-
-
Notifications
You must be signed in to change notification settings - Fork 2k
250 lines (216 loc) · 7.6 KB
/
release-python.yml
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
name: Release Python
on:
workflow_dispatch:
inputs:
# Latest commit to include with the release. If omitted, use the latest commit on the main branch.
sha:
description: Commit SHA
type: string
# Create the sdist and build the wheels, but do not publish to PyPI / GitHub.
dry-run:
description: Dry run
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: '3.8'
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
defaults:
run:
shell: bash
jobs:
create-sdist:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: [polars, polars-lts-cpu, polars-u64-idx]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}
# Avoid potential out-of-memory errors
- name: Set swap space for Linux
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Fix README symlink
run: rm py-polars/README.md && cp README.md py-polars/README.md
- name: Install yq
if: matrix.package != 'polars'
run: pip install yq
- name: Update package name
if: matrix.package != 'polars'
run: tomlq -i -t ".project.name = \"${{ matrix.package }}\"" py-polars/pyproject.toml
- name: Add bigidx feature
if: matrix.package == 'polars-u64-idx'
run: tomlq -i -t '.dependencies.polars.features += ["bigidx"]' py-polars/Cargo.toml
- name: Create source distribution
uses: PyO3/maturin-action@v1
with:
command: sdist
args: >
--manifest-path py-polars/Cargo.toml
--out dist
- name: Test sdist
run: |
TOOLCHAIN=$(grep -oP 'channel = "\K[^"]+' rust-toolchain.toml)
rustup default $TOOLCHAIN
pip install --force-reinstall --verbose dist/*.tar.gz
python -c 'import polars'
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: sdist
path: dist/*.tar.gz
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
package: [polars, polars-lts-cpu, polars-u64-idx]
os: [ubuntu-latest, macos-latest, windows-32gb-ram]
architecture: [x86-64, aarch64]
exclude:
- os: windows-32gb-ram
architecture: aarch64
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}
# Avoid potential out-of-memory errors
- name: Set swap space for Linux
if: matrix.os == 'ubuntu-latest'
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Fix README symlink
run: rm py-polars/README.md && cp README.md py-polars/README.md
- name: Install yq
if: matrix.package != 'polars'
run: pip install yq
- name: Update package name
if: matrix.package != 'polars'
run: tomlq -i -t ".project.name = \"${{ matrix.package }}\"" py-polars/pyproject.toml
- name: Add bigidx feature
if: matrix.package == 'polars-u64-idx'
run: tomlq -i -t '.dependencies.polars.features += ["bigidx"]' py-polars/Cargo.toml
- name: Set RUSTFLAGS for x86-64
if: matrix.architecture == 'x86-64' && matrix.package != 'polars-lts-cpu' && matrix.os != 'macos-latest'
run: echo "RUSTFLAGS=-C target-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+avx2,+fma,+bmi1,+bmi2,+lzcnt" >> $GITHUB_ENV
- name: Set RUSTFLAGS for x86-64 MacOS
if: matrix.architecture == 'x86-64' && matrix.package != 'polars-lts-cpu' && matrix.os == 'macos-latest'
run: echo "RUSTFLAGS=-C target-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx,+fma" >> $GITHUB_ENV
- name: Set RUSTFLAGS for x86-64 LTS CPU
if: matrix.architecture == 'x86-64' && matrix.package == 'polars-lts-cpu'
run: echo "RUSTFLAGS=-C target-feature=+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt --cfg use_mimalloc" >> $GITHUB_ENV
- name: Set Rust target for aarch64
if: matrix.architecture == 'aarch64'
id: target
run: |
TARGET=${{ matrix.os == 'macos-latest' && 'aarch64-apple-darwin' || 'aarch64-unknown-linux-gnu'}}
echo "target=$TARGET" >> $GITHUB_OUTPUT
- name: Set jemalloc for aarch64 Linux
if: matrix.architecture == 'aarch64' && matrix.os == 'ubuntu-latest'
run: |
echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> $GITHUB_ENV
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
command: build
target: ${{ steps.target.outputs.target }}
args: >
--release
--manifest-path py-polars/Cargo.toml
--out dist
manylinux: auto
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl
publish-to-pypi:
needs: [create-sdist, build-wheels]
environment:
name: release-python
url: https://pypi.org/project/polars
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download sdist
uses: actions/download-artifact@v3
with:
name: sdist
path: dist
- name: Download wheels
uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- name: Publish to PyPI
if: inputs.dry-run == false
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
publish-to-github:
needs: publish-to-pypi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.sha }}
- name: Download sdist
uses: actions/download-artifact@v3
with:
name: sdist
path: dist
- name: Get version from Cargo.toml
id: version
working-directory: py-polars
run: |
VERSION=$(grep -m 1 -oP 'version = "\K[^"]+' Cargo.toml)
if [[ "$VERSION" == *"-"* ]]; then
IS_PRERELEASE=true
else
IS_PRERELEASE=false
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "is_prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
- name: Create GitHub release
id: github-release
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter-python.yml
name: Python Polars ${{ steps.version.outputs.version }}
tag: py-${{ steps.version.outputs.version }}
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.is_prerelease }}
commitish: ${{ inputs.sha }}
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload sdist to GitHub release
run: gh release upload $TAG $FILES --clobber
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.github-release.outputs.tag_name }}
FILES: dist/polars-*.tar.gz
- name: Publish GitHub release
if: inputs.dry-run == false
run: gh release edit $TAG --draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.github-release.outputs.tag_name }}