-
Notifications
You must be signed in to change notification settings - Fork 0
428 lines (402 loc) · 16.1 KB
/
build.yml
File metadata and controls
428 lines (402 loc) · 16.1 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
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
name: Build
on:
push:
branches: ['main']
pull_request:
branches: ['main']
workflow_run:
workflows: ['clear-cache']
types: ['completed']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
fetch:
name: Fetch
runs-on: ubuntu-latest
outputs:
py: ${{ steps.info.outputs.py }}
ios: ${{ steps.info.outputs.ios }}
bz2: ${{ steps.ver.outputs.bz2 }}
ffi: ${{ steps.ver.outputs.ffi }}
xz: ${{ steps.ver.outputs.xz }}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Get build information from build.toml
id: info
run: |
echo "py=$(yq .build.py build.toml -oj)" >> $GITHUB_OUTPUT
echo "ios=$(yq .build.ios build.toml)" >> $GITHUB_OUTPUT
- name: Get library version information from build.toml
id: ver
run: |
echo "bz2=$(yq .lib.bz2 build.toml)" >> $GITHUB_OUTPUT
echo "ffi=$(yq .lib.ffi build.toml)" >> $GITHUB_OUTPUT
echo "xz=$(yq .lib.xz build.toml)" >> $GITHUB_OUTPUT
build-bz2:
name: Build bzip2
needs: fetch
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
build:
- target: 'iphoneos.arm64'
sdk: 'iphoneos'
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}'
- target: 'iphonesimulator.arm64'
sdk: 'iphonesimulator'
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator'
- target: 'iphonesimulator.x86_64'
sdk: 'iphonesimulator'
host: 'x86_64-apple-ios${{ needs.fetch.outputs.ios }}-simulator'
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Cache bzip2
id: cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/install/bz2
key: bz2-${{ needs.fetch.outputs.bz2 }}-${{ matrix.build.host }}
- name: Download bzip2 source
run: |
curl -O https://www.sourceware.org/pub/bzip2/bzip2-${{ needs.fetch.outputs.bz2 }}.tar.gz
tar -xf bzip2-${{ needs.fetch.outputs.bz2 }}.tar.gz
- name: Build bzip2
working-directory: bzip2-${{ needs.fetch.outputs.bz2 }}
run: >
make install
PREFIX="${{ github.workspace }}/install/bz2"
CC="xcrun --sdk ${{ matrix.build.sdk }} clang -target ${{ matrix.build.host }}"
CFLAGS="--sysroot=$(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}"
LDFLAGS="-isysroot $(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}"
- name: Upload the bzip2 artifact
uses: actions/upload-artifact@v4
with:
name: bz2-${{ matrix.build.host }}
path: ${{ github.workspace }}/install/bz2
if-no-files-found: error
retention-days: 1
build-ffi:
name: Build libffi
needs: fetch
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
build:
- target: 'iphoneos.arm64'
sdk: 'iphoneos'
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}'
- target: 'iphonesimulator.arm64'
sdk: 'iphonesimulator'
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator'
- target: 'iphonesimulator.x86_64'
sdk: 'iphonesimulator'
host: 'x86_64-apple-ios${{ needs.fetch.outputs.ios }}-simulator'
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Cache libffi
id: cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/install/ffi
key: ffi-${{ needs.fetch.outputs.ffi }}-${{ matrix.build.host }}
- name: Download libffi source
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: >
gh release
-R libffi/libffi
download v${{ needs.fetch.outputs.ffi }}
-p libffi-${{ needs.fetch.outputs.ffi }}.tar.gz
env:
GH_TOKEN: ${{ github.token }}
- name: Extract libffi tarball
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: tar -xzf libffi-${{ needs.fetch.outputs.ffi }}.tar.gz
- name: Configure libffi build
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
working-directory: libffi-${{ needs.fetch.outputs.ffi }}
run: >
./configure
--prefix="${{ github.workspace }}/install/ffi"
--build=$(uname -m)-apple-darwin
--host=${{ matrix.build.host }}
--disable-shared
--enable-static
CC="xcrun --sdk ${{ matrix.build.sdk }} clang -target ${{ matrix.build.host }}"
CFLAGS="--sysroot=$(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}"
LDFLAGS="-isysroot $(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}"
- name: Build libffi
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
working-directory: libffi-${{ needs.fetch.outputs.ffi }}
run: |
make
make install
- name: Upload the libffi artifact
uses: actions/upload-artifact@v4
with:
name: ffi-${{ matrix.build.host }}
path: ${{ github.workspace }}/install/ffi
if-no-files-found: error
retention-days: 1
build-xz:
name: Build XZ Utils
needs: fetch
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
build:
- target: 'iphoneos.arm64'
sdk: 'iphoneos'
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}'
- target: 'iphonesimulator.arm64'
sdk: 'iphonesimulator'
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator'
- target: 'iphonesimulator.x86_64'
sdk: 'iphonesimulator'
host: 'x86_64-apple-ios${{ needs.fetch.outputs.ios }}-simulator'
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Cache XZ Utils
id: cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/install/xz
key: xz-${{ needs.fetch.outputs.xz }}-${{ matrix.build.host }}
- name: Download XZ Utils source
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: >
gh release
-R tukaani-project/xz
download v${{ needs.fetch.outputs.xz }}
-p xz-${{ needs.fetch.outputs.xz }}.tar.gz
env:
GH_TOKEN: ${{ github.token }}
- name: Extract XZ Utils tarball
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: tar -xzf xz-${{ needs.fetch.outputs.xz }}.tar.gz
- name: Apply patch
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
working-directory: xz-${{ needs.fetch.outputs.xz }}
run: |
patch -u ./build-aux/config.sub ${{ github.workspace }}/patch/xz.patch
- name: Configure XZ Utils build
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
working-directory: xz-${{ needs.fetch.outputs.xz }}
run: >
./configure
--prefix="${{ github.workspace }}/install/xz"
--host=${{ matrix.build.host }}
--disable-shared
--enable-static
CC="xcrun --sdk ${{ matrix.build.sdk }} clang -target ${{ matrix.build.host }}"
CFLAGS="--sysroot=$(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}"
LDFLAGS="-isysroot $(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}"
- name: Build XZ Utils
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
working-directory: xz-${{ needs.fetch.outputs.xz }}
run: |
make
make install
- name: Upload the XZ Utils artifact
uses: actions/upload-artifact@v4
with:
name: xz-${{ matrix.build.host }}
path: ${{ github.workspace }}/install/xz
if-no-files-found: error
retention-days: 1
build-python-framework:
name: Build Python.framework
needs: [fetch, build-bz2, build-ffi, build-xz]
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.13-dev']
build:
- host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}'
- host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator'
- host: 'x86_64-apple-ios${{ needs.fetch.outputs.ios }}-simulator'
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
id: py
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Set version information
id: pyver
run: |
echo "py=$(python -V | cut -wf 2)" >> $GITHUB_OUTPUT
- name: Clone python/cpython ${{ matrix.python-version }}
run: >
gh repo clone python/cpython
-- -b v${{ steps.pyver.outputs.py }} --depth=1
env:
GH_TOKEN: ${{ github.token }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/install
pattern: '*-${{ matrix.build.host }}'
- name: Add iOS/Resources/bin to PATH
working-directory: cpython
run: echo "${{ github.workspace }}/cpython/iOS/Resources/bin" >> $GITHUB_PATH
- name: Configure Python build
working-directory: cpython
run: >
./configure
BZIP2_CFLAGS="-I${{ github.workspace }}/install/bz2-${{ matrix.build.host }}/include"
BZIP2_LIBS="-L${{ github.workspace }}/install/bz2-${{ matrix.build.host }}/lib -lbz2"
LIBFFI_CFLAGS="-I${{ github.workspace }}/install/ffi-${{ matrix.build.host }}/include"
LIBFFI_LIBS="-L${{ github.workspace }}/install/ffi-${{ matrix.build.host }}/lib -lffi"
LIBLZMA_CFLAGS="-I${{ github.workspace }}/install/xz-${{ matrix.build.host }}/include"
LIBLZMA_LIBS="-L${{ github.workspace }}/install/xz-${{ matrix.build.host }}/lib -llzma"
--enable-framework="${{ github.workspace }}/framework"
--build=$(uname -m)-apple-darwin
--host=${{ matrix.build.host }}
--with-build-python="${{ steps.py.outputs.python-path }}"
- name: Build Python.framework
working-directory: cpython
run: |
make
make install
- name: Upload Python.framework
uses: actions/upload-artifact@v4
with:
name: cp${{ matrix.python-version }}-${{ matrix.build.host }}
path: ${{ github.workspace }}/framework
if-no-files-found: error
retention-days: 1
create-iphoneos-framework:
name: Create Python.framework for iphoneos
needs: [fetch, build-python-framework]
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.13-dev']
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/frameworks
pattern: 'cp${{ matrix.python-version }}-arm64-apple-ios${{ needs.fetch.outputs.ios }}'
- name: Copy iphoneos framework
working-directory: frameworks
run: >
cp
cp${{ matrix.python-version }}-arm64-apple-ios${{ needs.fetch.outputs.ios }}
cp${{ matrix.python-version }}-iphoneos
- name: Upload Python.framework
uses: actions/upload-artifact@v4
with:
name: cp${{ matrix.python-version }}-iphoneos
path: ${{ github.workspace }}/frameworks/cp${{ matrix.python-version }}-iphoneos
if-no-files-found: error
retention-days: 1
create-iphonesimulator-framework:
name: Create Python.framework for iphonesimulator
needs: [fetch, build-python-framework]
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.13-dev']
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/frameworks
pattern: 'cp${{ matrix.python-version }}-*-apple-ios${{ needs.fetch.outputs.ios }}-simulator'
- name: Copy binaries
working-directory: frameworks
run: >
cp
cp${{ matrix.python-version }}-arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator/bin
cp${{ matrix.python-version }}-iphonesimulator/bin
- name: Copy standard libraries
working-directory: frameworks
run: >
cp
cp${{ matrix.python-version }}-arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator/lib
cp${{ matrix.python-version }}-iphonesimulator/lib
- name: Create a new framework directory
working-directory: frameworks
run: |
mkdir -p cp${{ matrix.python-version }}-iphonesimulator/Python.framework
- name: Copy headers
working-directory: frameworks
run: >
cp
cp${{ matrix.python-version }}-arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator/Python.framework/Headers
cp${{ matrix.python-version }}-iphonesimulator/Python.framework/Headers
- name: Copy pyconfig-arm64.h
working-directory: frameworks
run: >
cp
cp${{ matrix.python-version }}-arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator/Python.framework/Headers/pyconfig.h
cp${{ matrix.python-version }}-iphonesimulator/Python.framework/Headers/pyconfig-arm64.h
- name: Copy pyconfig-x86_64.h
working-directory: frameworks
run: >
cp
cp${{ matrix.python-version }}-x86_64-apple-ios${{ needs.fetch.outputs.ios }}-simulator/Python.framework/Headers/pyconfig.h
cp${{ matrix.python-version }}-iphonesimulator/Python.framework/Headers/pyconfig-x86_64.h
- name: Copy Info.plist
working-directory: frameworks
run: >
cp
cp${{ matrix.python-version }}-arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator/Python.framework/Info.plist
cp${{ matrix.python-version }}-iphonesimulator/Python.framework/Info.plist
- name: Merge iphoneossimulator farmeworks
working-directory: frameworks
run: >
lipo -create
-output cp${{ matrix.python-version }}-iphonesimulator/Python.framework/Python
cp${{ matrix.python-version }}-arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator/Python.framework/Python
cp${{ matrix.python-version }}-x86_64-apple-ios${{ needs.fetch.outputs.ios }}-simulator/Python.framework/Python
- name: Delete platform-specific files
working-directory: frameworks/cp${{ matrix.python-version }}-iphonesimulator/lib/
run: |
rm -r
- name: Upload Python.framework
uses: actions/upload-artifact@v4
with:
name: cp${{ matrix.python-version }}-iphonesimulator
path: ${{ github.workspace }}/frameworks/cp${{ matrix.python-version }}-arm64-apple-ios${{ needs.fetch.outputs.ios }}
if-no-files-found: error
retention-days: 1
create-xcframework:
name: Build Python.xcframework
needs: [create-iphoneos-framework, create-iphonesimulator-framework]
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.13-dev']
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
- name: Download Python.framework for iphoneos
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/frameworks
pattern: 'cp${{ matrix.python-version }}-iphoneos'
- name: Download Python.framework for iphonesimulator
uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/frameworks
pattern: 'cp${{ matrix.python-version }}-iphonesimulator'