-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (241 loc) · 7.44 KB
/
build_wheel.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
name: Build Wheels
on:
push:
branches: ["master"]
paths: [".github/workflows/build_wheel.yml", "dither_go/**", "!dither_go/bindings/**"]
pull_request:
paths: [".github/workflows/build_wheel.yml", "dither_go/**", "!dither_go/bindings/**"]
workflow_dispatch:
workflow_call:
jobs:
build_sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
run: pipx run build --sdist
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: source
path: dist/*.tar.gz
build_macos:
#if: false
name: MacOS ${{ matrix.arch_cibw_go[0] }}
strategy:
fail-fast: false
matrix:
arch_cibw_go:
- [ "x86_64", "amd64" ]
- [ "arm64", "arm64" ]
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
- name: Install gopy
run: go install github.com/go-python/gopy@v0.4.7
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Build wheels
run: ./tools/macos_build_wheels.sh
env:
CIBW_ARCHS: ${{ matrix.arch_cibw_go[0] }}
CIBW_BUILD_FRONTEND: "build"
PYTHON_BINARY_PATH: /usr/local/bin/python_for_build
CIBW_ENVIRONMENT: >
PATH=$PATH:/usr/local/go/bin
GOARCH=${{ matrix.arch_cibw_go[1] }}
CGO_ENABLED=1
MACOSX_DEPLOYMENT_TARGET=10.15
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
build_linux_x86_64:
#if: false
name: Linux x86_64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build wheels
uses: pypa/cibuildwheel@v2.15.0
with:
package-dir: .
env:
CIBW_BUILD: "cp3*_x86_64"
CIBW_BUILD_FRONTEND: "build"
CIBW_SKIP: "cp36-* cp37-* *-musllinux_x86_64"
CIBW_ARCHS: "native"
CIBW_ENVIRONMENT: >
PATH=$PATH:/usr/local/go/bin
CGO_ENABLED=1
CIBW_BEFORE_ALL_LINUX: |
curl -o go.tar.gz https://dl.google.com/go/go1.20.7.linux-amd64.tar.gz
tar -C /usr/local -xzf go.tar.gz
go install github.com/go-python/gopy@v0.4.7
go install golang.org/x/tools/cmd/goimports@latest
./tools/linux_compile_libwebp.sh
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
build_linux_arm64:
#if: false
name: Linux arm64
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python3_version: [ 8, 9, 10, 11 ]
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build 3.${{ matrix.python3_version }} wheels
uses: pypa/cibuildwheel@v2.15.0
with:
package-dir: .
env:
CIBW_BUILD: "cp3${{ matrix.python3_version }}*_aarch64"
CIBW_BUILD_FRONTEND: "build"
CIBW_SKIP: "cp36-* cp37-* *-musllinux_aarch64"
CIBW_ARCHS: "aarch64"
CIBW_ENVIRONMENT: >
PATH=$PATH:/usr/local/go/bin
CGO_ENABLED=1
CIBW_BEFORE_ALL_LINUX: |
curl -o go.tar.gz https://dl.google.com/go/go1.20.7.linux-arm64.tar.gz
tar -C /usr/local -xzf go.tar.gz
go install github.com/go-python/gopy@v0.4.7
go install golang.org/x/tools/cmd/goimports@latest
./tools/linux_compile_libwebp.sh
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
build_linux_armv7l:
if: false # Disable for now; It can't find source files for some reason
name: Linux armv7l
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python3_version: [ 8, 9, 10, 11 ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build 3.${{ matrix.python3_version }} wheels via Docker
uses: docker/build-push-action@v3
with:
context: .
file: ./tools/Dockerfile.armv7l
build-args: |
PYTHON3_VERSION=${{ matrix.python3_version }}
push: false
platforms: linux/armhf
tags: armv7l:latest
load: true
- name: Extract output
run: |
docker run -v /tmp/output:/host armv7l:latest bash -c "cp /export/* /host/"
tar -zcvf /tmp/output.tar.gz /tmp/output
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: /tmp/output/*.whl
build_windows:
if: false # TODO: Modify to use MinGW instead
name: Windows x86_64
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: ilammy/msvc-dev-cmd@v1
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
# TODO: Make a fork of this fork to update to 0.4.7
- name: Install gopy
run: |
cd $env:TEMP
git clone https://github.com/bjia56/gopy
cd gopy
git checkout v0.4.5+bjia56.v1
go install -v
gopy
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Compile Libwebp
run: |
curl -o libwebp.tar.gz https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.3.1.tar.gz
tar -xzf libwebp.tar.gz
cd libwebp-1.3.1
nmake /f Makefile.vc CFG=release-dynamic RTLIBCFG=dynamic OBJDIR=output
- name: Build wheels
uses: pypa/cibuildwheel@v2.15.0
with:
package-dir: .
env:
CIBW_BUILD: "cp3*"
CIBW_BUILD_FRONTEND: "build"
CIBW_SKIP: "cp36-* cp37-*"
CIBW_ARCHS: "native"
CIBW_ENVIRONMENT: >
GOARCH=amd64
CGO_ENABLED=1
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
upload_to_pypi:
name: Upload to PyPI
needs:
- build_sdist
- build_macos
- build_linux_x86_64
- build_linux_arm64
#- build_linux_armv7l
#- build_windows
runs-on: ubuntu-latest
environment: pypi-upload
permissions:
id-token: write
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Get source distribution
uses: actions/download-artifact@v3
with:
name: source
path: dist
- name: Get all built distributions
uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
all_builds_passed:
needs:
- build_sdist
- build_macos
- build_linux_x86_64
- build_linux_arm64
#- build_linux_armv7l
#- build_windows
runs-on: ubuntu-latest
steps:
- run: |
echo "All builds passed!"