-
Notifications
You must be signed in to change notification settings - Fork 4
295 lines (251 loc) · 8.75 KB
/
build_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
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
name: Build Python
on:
workflow_dispatch:
inputs:
python_version:
required: true
type: string
platforms:
required: true
type: string
default: "linux-x86_64,linux-aarch64,linux-i386,linux-arm,linux-riscv64,macos,windows"
buildsystem_branch:
required: false
type: string
default: "portable-python"
run_tests:
required: false
type: boolean
debug:
required: false
type: boolean
debug_interactive:
required: false
type: boolean
verbose:
required: false
type: boolean
workflow_call:
inputs:
python_version:
required: true
type: string
platforms:
required: true
type: string
buildsystem_branch:
required: false
type: string
run_tests:
required: false
type: boolean
debug:
required: false
type: boolean
verbose:
required: false
type: boolean
env:
RUN_TESTS: ${{ inputs.run_tests }}
DEBUG_CI: ${{ inputs.debug }}
VERBOSE_CI: ${{ inputs.verbose }}
PORTABLE_PYTHON_BUILDSYSTEM_BRANCH: ${{ inputs.buildsystem_branch || 'portable-python' }}
image_map: '{"x86_64": "amd64/centos:7", "i386": "i386/centos:7", "aarch64": "arm64v8/centos:7", "arm": "arm32v7/debian:bullseye", "riscv64": "riscv64/debian:sid"}'
jobs:
build_linux:
name: Linux ${{ inputs.python_version }} ${{ matrix.arch }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [x86_64, i386, aarch64, arm, riscv64]
exclude:
- arch: ${{ !contains(inputs.platforms, 'linux-x86_64') && 'x86_64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-i386') && 'i386' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-aarch64') && 'aarch64' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-arm') && 'arm' || '' }}
- arch: ${{ !contains(inputs.platforms, 'linux-riscv64') && 'riscv64' || '' }}
steps:
- name: Parse image
if: ${{ matrix.arch }}
id: parse_image
run: |
IMAGE=$(echo ${{ toJSON(env.image_map) }} | jq -r '.["${{ matrix.arch }}"]')
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
- name: Set up zig
if: ${{ matrix.arch }}
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.12.0-dev.3097+5c0766b6c
- name: Checkout
if: ${{ matrix.arch }}
uses: actions/checkout@v4
- name: Build
if: ${{ matrix.arch }}
run: |
./scripts/build_linux_zig.sh ${{ matrix.arch }} ${{ inputs.python_version }}
- name: Interactive debugging
if: ${{ always() && matrix.arch && inputs.debug_interactive }}
uses: fawazahmed0/action-debug@v2
- name: Upload artifacts
if: ${{ matrix.arch }}
uses: actions/upload-artifact@v4
with:
name: python-linux-${{ matrix.arch }}-${{ inputs.python_version }}
path: ./python*.zip
- name: Upload artifacts
if: ${{ always() && matrix.arch && inputs.debug }}
uses: actions/upload-artifact@v4
with:
name: build-python-linux-${{ matrix.arch }}-${{ inputs.python_version }}
path: ./*python*.tar.gz
- name: Test python in clean environment
if: ${{ matrix.arch }}
uses: addnab/docker-run-action@v3
with:
image: ${{ steps.parse_image.outputs.image }}
options: -v ${{ github.workspace }}:/work --workdir /tmp
shell: bash
run: |
set -e
uname -a
if [ "${{ matrix.arch }}" == "arm" ] || [ "${{ matrix.arch }}" == "riscv64" ]; then
apt update
apt -y install unzip
else
yum -y install unzip
fi
cp /work/python*.zip .
unzip ./python*.zip
cd python-${{ inputs.python_version }}-linux-${{ matrix.arch }}
chmod +x ./bin/python
ldd -v -r ./bin/python
./bin/python --version
./bin/python -m sysconfig
./bin/python /work/scripts/test.py
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
build_windows:
name: Windows ${{ inputs.python_version }} x86_64 (build)
if: ${{ contains(inputs.platforms, 'windows') }}
runs-on: windows-latest
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v4
- name: Configure build for x86_64
uses: ilammy/[email protected]
- name: Remove Strawberry
shell: pwsh
run: |
Rename-Item c:\strawberry strawberry2
- name: Build
shell: bash
run: |
set -ex
./scripts/build_windows.sh x86_64 ${{ inputs.python_version }}
- name: Interactive debugging
uses: fawazahmed0/action-debug@v2
if: ${{ always() && inputs.debug_interactive }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-windows-x86_64-${{ inputs.python_version }}
path: ./python*.zip
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ always() && inputs.debug }}
with:
name: build-python-windows-x86_64-${{ inputs.python_version }}
path: ./*python*.tar.gz
test_windows:
name: Windows ${{ inputs.python_version }} x86_64 (test)
needs: build_windows
runs-on: windows-latest
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: python-windows-x86_64-${{ inputs.python_version }}
path: ./python/
- name: Test python in clean environment
shell: bash
run: |
7z.exe x python/python-${{ inputs.python_version }}-windows-x86_64.zip
cd python-${{ inputs.python_version }}-windows-x86_64
./bin/python --version
./bin/python -m sysconfig
./bin/python ../scripts/test.py
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi
build_macos:
name: MacOS ${{ inputs.python_version }} universal2 (build)
if: ${{ contains(inputs.platforms, 'macos') }}
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install coreutils
run: brew install coreutils gpatch autoconf automake libtool
- name: Build
run: |
set -ex
./scripts/build_macos.sh universal2 ${{ inputs.python_version }}
- name: Interactive debugging
uses: fawazahmed0/action-debug@v2
if: ${{ always() && inputs.debug_interactive }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-darwin-universal2-${{ inputs.python_version }}
path: ./python*.zip
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ always() && inputs.debug }}
with:
name: build-python-darwin-universal2-${{ inputs.python_version }}
path: ./*python*.tar.gz
test_macos:
name: MacOS ${{ inputs.python_version }} ${{ matrix.arch }} (test)
needs: build_macos
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ macos-11, macos-14 ]
include:
- os: macos-11
arch: x86_64
- os: macos-14
arch: arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: python-darwin-universal2-${{ inputs.python_version }}
path: ./python/
- name: Test python in clean environment
shell: bash
run: |
unzip python/python-${{ inputs.python_version }}-darwin-universal2.zip
cd python-${{ inputs.python_version }}-darwin-universal2
chmod +x ./bin/python
./bin/python --version
./bin/python -m sysconfig
./bin/python ${{ github.workspace }}/scripts/test.py
if [[ "${{ inputs.run_tests }}" == "true" ]]; then
./bin/python -m test -v -ulargefile,network,decimal,cpu,subprocess,urlfetch,tzdata --timeout 60
fi