-
Notifications
You must be signed in to change notification settings - Fork 2
316 lines (280 loc) · 9.74 KB
/
build.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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# Initial workflow for building manylinux wheel using `maturin` forked from:
# https://github.com/konstin/complex-manylinux-maturin-dockers
name: Build
on:
push:
branches:
- main
pull_request:
jobs:
# ============ #
# Linux Wheels #
# ============ #
#
# Build and test Linux wheels.
#
manylinux-wheels-via-rust-stable:
name: manylinux wheels via Rust stable
runs-on: ubuntu-latest
container: quay.io/pypa/manylinux2014_x86_64
steps:
# Checkout the repo.
- uses: actions/checkout@v1
# Install Rust.
- name: Install stable Rust toolchain
# # # run: curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true
# Install Nox.
- name: Install Nox
# (Only need to run Nox with python 3.9, it will launch other pythons.)
run: |
source $HOME/.cargo/env
for PYBIN in /opt/python/cp3[9]*/bin; do
$PYBIN/python -m pip install nox
done
# Insert steps here to install your other dependencies. Note that you're running inside of cent os 7, not ubuntu
#
# For example:
# - name: Installing custom dependency
# run: echo "Installing custom dependency"
- name: Install openssl-devel
run: yum install -y openssl-devel
# Build the wheels.
- name: Build wheels
run: |
source $HOME/.cargo/env
for PYBIN in /opt/python/cp3[6789]*/bin; do
"${PYBIN}/pip" install maturin
"${PYBIN}/maturin" build -m Cargo.toml -i "${PYBIN}/python" --release --manylinux 2014
done
# Auditwheel repair.
#
# Auditwheel isn't generally necessary. This is only shown as reference for cases where you link external libraries, in which case you have to set manylinux to off and then use `auditwheel repair`.
#
# For example:
# - name: Auditwheel repair
# run: |
# for wheel in nightly-only/target/wheels/*.whl; do
# auditwheel repair "${wheel}"
# done
# Debug print some directories.
- name: Debug Print Dirs
run: |
echo "ls working directory..."
ls
echo "ls target/wheels..."
ls target/wheels
# Run tests on all the supported/installed pythons.
# # # - uses: excitedleigh/[email protected]
- name: Run Nox
# (Only need to run Nox with python 3.9, it will launch other pythons.)
run: |
source $HOME/.cargo/env
for PYBIN in /opt/python/cp3[9]*/bin; do
$PYBIN/python -m nox
done
# Upload target/wheels.
- name: Upload target/wheels
uses: actions/upload-artifact@v2
with:
name: manylinux-wheels
path: target/wheels
# ============ #
# macOS Wheels #
# ============ #
#
# Build and test macOS wheels.
#
macos-wheels-via-rust-stable:
name: macOS wheels via Rust stable
# For now we build for macOS Catalina (macos-10.15) - Big Sur maybe later? -2021-06-16
runs-on: macos-10.15
steps:
- uses: actions/checkout@v1
# Install Pythons.
- uses: actions/setup-python@v2
with:
python-version: '3.6'
- run: echo "PY_3_6=$(python -c "import sys; print(sys.executable)")" >> $GITHUB_ENV
- uses: actions/setup-python@v2
with:
python-version: '3.7'
- run: echo "PY_3_7=$(python -c "import sys; print(sys.executable)")" >> $GITHUB_ENV
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- run: echo "PY_3_8=$(python -c "import sys; print(sys.executable)")" >> $GITHUB_ENV
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- run: echo "PY_3_9=$(python -c "import sys; print(sys.executable)")" >> $GITHUB_ENV
# Install nox.
- name: Install nox
# (Only need to run Nox with python 3.9, it will launch other pythons.)
run: |
echo "Install nox..."
$PY_3_9 -m pip install nox
# Install Rust.
- name: Install stable Rust toolchain
# # # run: curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true
# Build wheels.
- name: Build wheels
run: |
for PYTHON in $PY_3_6 $PY_3_7 $PY_3_8 $PY_3_9
do
echo "Building with $PYTHON..."
$PYTHON -m pip install maturin
maturin build --release -i $PYTHON
done
# Debug print some directories.
- name: Debug Print Dirs
run: |
echo "ls working directory..."
ls
echo "ls target/wheels..."
ls target/wheels
# Run tests on all the supported/installed pythons.
# # # - uses: excitedleigh/[email protected]
- name: Run Nox
# (Only need to run Nox with python 3.9, it will launch other pythons.)
run: $PY_3_9 -m nox
# Upload target/wheels.
- name: Upload target/wheels
uses: actions/upload-artifact@v2
with:
name: macos-wheels
path: target/wheels
# ============== #
# Windows Wheels #
# ============== #
#
# Build and test Windows wheels.
#
windows-wheels-via-rust-stable:
name: Windows wheels via Rust stable
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v1
# Install Pythons and store their executables into specific env vars.
- uses: actions/setup-python@v2
with:
python-version: '3.6'
- run: echo "PY_3_6=$(python -c "import sys; print(sys.executable)")" >> $env:GITHUB_ENV
- uses: actions/setup-python@v2
with:
python-version: '3.7'
- run: echo "PY_3_7=$(python -c "import sys; print(sys.executable)")" >> $env:GITHUB_ENV
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- run: echo "PY_3_8=$(python -c "import sys; print(sys.executable)")" >> $env:GITHUB_ENV
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- run: echo "PY_3_9=$(python -c "import sys; print(sys.executable)")" >> $env:GITHUB_ENV
# Run tests on all the supported/installed pythons.
# # # - uses: excitedleigh/[email protected]
- name: Setup Nox
# (Only need to run Nox with python 3.9, it will launch other pythons.)
run: |
foreach ($PYTHON in @($env:PY_3_9)) {
.$PYTHON -m pip install nox
}
# Attempt to cache OpenSSL.
- name: Cache Win64 OpenSSL
id: cache-win64-openssl
uses: actions/cache@v2
with:
path: 'C:\Program Files\OpenSSL-Win64'
key: win64-openssl
# key: ${{ runner.os }}-openssl
# Install OpenSSL if we don't have it cached.
- name: Install OpenSSL via chocolatey (line-heavy output, causes page lag)
if: steps.cache-win64-openssl.outputs.cache-hit != 'true'
uses: nickjbenson/ghaction-chocolatey@master
with:
args: install openssl -y -r
# (It should now cache at C:\Program Files\OpenSSL-Win64)
# Install Rust.
- name: Install stable Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true
# Build wheels.
- name: Build wheels
run: |
# Note: Manually ref install dir for OpenSSL
$Env:OPENSSL_DIR='C:\Program Files\OpenSSL-Win64'
foreach ($PYTHON in @($env:PY_3_6, $env:PY_3_7, $env:PY_3_8, $env:PY_3_9)) {
echo "Building with $($PYTHON)..."
.$PYTHON -m pip install maturin
maturin build --release -i $PYTHON
}
# Run tests on all the supported/installed pythons.
# # # - uses: excitedleigh/[email protected]
- name: Run Nox
# (Only need to run Nox with python 3.9, it will launch other pythons.)
run: |
foreach ($PYTHON in @($env:PY_3_9)) {
.$PYTHON -m nox
}
# Upload wheels.
- name: Upload target/wheels
uses: actions/upload-artifact@v1
with:
name: windows-wheels
path: target/wheels
# ===================== #
# Upload Wheels to PyPI #
# ===================== #
#
upload-wheels-to-pip:
# Only upload to pip if this is a commit on the main branch!
if: github.ref == 'refs/heads/main'
name: Upload Windows, macOS, and Linux wheels to pip
needs: [
manylinux-wheels-via-rust-stable,
windows-wheels-via-rust-stable,
macos-wheels-via-rust-stable
]
runs-on: ubuntu-latest
environment: pypi_publishing_environment
steps:
- name: Download Linux wheel artifacts
uses: actions/download-artifact@v2
with:
name: manylinux-wheels
- name: Download macOS wheel artifacts
uses: actions/download-artifact@v2
with:
name: macos-wheels
- name: Download Windows wheel artifacts
uses: actions/download-artifact@v2
with:
name: windows-wheels
- name: Setup Python 3.9 & pip
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Upload to pip
env:
MATURIN_PIP_TOKEN: ${{ secrets.MATURIN_PIP_TOKEN }}
run: |
pip install maturin
for WHEEL in *.whl
do
echo "Attempting to upload $(echo $WHEEL)"
maturin upload --skip-existing -u __token__ -p $MATURIN_PIP_TOKEN $WHEEL
done