Repository navigation
205 lines (199 loc) · 7.19 KB
/
Copy pathbuild-native-pr.yml
File metadata and controls
205 lines (199 loc) · 7.19 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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# All `uses:` action pins in this workflow must come from the Apache action allowlist:
# https://github.com/apache/infrastructure-actions/blob/main/actions.yml
name: Build Native PR Wheels
on:
pull_request:
paths: [ci/**, python/**, .github/workflows/**]
push:
branches: [main]
paths: [ci/**, python/**, .github/workflows/**]
jobs:
build-windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.14']
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-python@v7.0.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Set up Bazel
uses: bazel-contrib/setup-bazel@104e3eea9447cdaa4b00d0fb46191a3985d26ab3 # 0.19.1
with:
bazelisk-cache: true
bazelisk-version: '1.x'
- name: Build wheel
run: ./ci/deploy.sh build_pyfory
shell: bash
- name: Install and verify wheel
shell: bash
run: |
python -m pip install --upgrade pip
pip install dist/*.whl
python -c "import pyfory; print(pyfory.__version__)"
- name: Upload wheels as artifacts
uses: actions/upload-artifact@v7
with:
name: pyfory-wheels-native-windows-${{ matrix.python-version }}
path: dist/*.whl
build-macos-arm64:
runs-on: macos-15
strategy:
matrix:
python-version: ['3.14']
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-python@v7.0.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Set up Bazel
uses: bazel-contrib/setup-bazel@104e3eea9447cdaa4b00d0fb46191a3985d26ab3 # 0.19.1
with:
bazelisk-cache: true
bazelisk-version: '1.x'
- name: Build wheel
run: ./ci/deploy.sh build_pyfory
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
PYFORY_WHEEL_PLAT: macosx_11_0_arm64
- name: Install and verify wheel
shell: bash
run: |
python -m pip install --upgrade pip
pip install dist/*.whl
python -c "import pyfory; print(pyfory.__version__)"
- name: Upload wheel artifact
uses: actions/upload-artifact@v7
with:
name: pyfory-macos-arm64-wheel-${{ matrix.python-version }}
path: dist/*.whl
build-macos-x86_64:
runs-on: macos-15-intel
strategy:
matrix:
python-version: ['3.14']
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-python@v7.0.0
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Set up Bazel
uses: bazel-contrib/setup-bazel@104e3eea9447cdaa4b00d0fb46191a3985d26ab3 # 0.19.1
with:
bazelisk-cache: true
bazelisk-version: '1.x'
- name: Build wheel
run: ./ci/deploy.sh build_pyfory
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
PYFORY_WHEEL_PLAT: macosx_11_0_x86_64
- name: Install and verify wheel
shell: bash
run: |
python -m pip install --upgrade pip
pip install dist/*.whl
python -c "import pyfory; print(pyfory.__version__)"
- name: Upload wheel artifact
uses: actions/upload-artifact@v7
with:
name: pyfory-macos-x86_64-wheel-${{ matrix.python-version }}
path: dist/*.whl
merge-macos-universal2:
runs-on: macos-15
needs: [build-macos-arm64, build-macos-x86_64]
strategy:
matrix:
python-version: ['3.14']
steps:
- uses: actions/setup-python@v7.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install wheel tooling
run: python -m pip install --upgrade pip wheel
- name: Download arch wheels
uses: actions/download-artifact@v8
with:
pattern: pyfory-macos-*-wheel-${{ matrix.python-version }}
path: artifacts
merge-multiple: true
- name: Build universal2 wheel
shell: bash
run: |
set -euo pipefail
mkdir -p unpacked dist
ARM_WHL=$(ls artifacts/*arm64*.whl | head -n1)
X86_WHL=$(ls artifacts/*x86_64*.whl | head -n1)
python -m wheel unpack "$ARM_WHL" -d unpacked/arm64
python -m wheel unpack "$X86_WHL" -d unpacked/x86_64
ARM_DIR=$(ls -d unpacked/arm64/pyfory-*)
X86_DIR=$(ls -d unpacked/x86_64/pyfory-*)
UNIVERSAL_DIR="unpacked/pyfory-universal2"
cp -R "$ARM_DIR" "$UNIVERSAL_DIR"
SO_FILES=$(cd "$ARM_DIR" && find pyfory -name '*.so' -type f | sort)
if [[ -z "$SO_FILES" ]]; then
echo "No shared libraries found in wheel payload"
exit 1
fi
for so in $SO_FILES; do
if [[ ! -f "$X86_DIR/$so" ]]; then
echo "Missing matching x86_64 library for $so"
exit 1
fi
lipo -create "$ARM_DIR/$so" "$X86_DIR/$so" -output "$UNIVERSAL_DIR/$so"
done
WHEEL_FILE=$(ls "$UNIVERSAL_DIR"/pyfory-*.dist-info/WHEEL)
sed -i '' -e 's/macosx_11_0_arm64/macosx_11_0_universal2/g' \
-e 's/macosx_11_0_x86_64/macosx_11_0_universal2/g' \
"$WHEEL_FILE"
python -m wheel pack "$UNIVERSAL_DIR" -d dist
- name: Verify universal2 binaries
shell: bash
run: |
set -euo pipefail
mkdir -p verify
for whl in dist/*.whl; do
python -m wheel unpack "$whl" -d verify
done
VERIFY_DIR=$(ls -d verify/pyfory-*)
WHEEL_FILE=$(ls "$VERIFY_DIR"/pyfory-*.dist-info/WHEEL)
grep -q "macosx_11_0_universal2" "$WHEEL_FILE"
SO_FILES=$(cd "$VERIFY_DIR" && find pyfory -name '*.so' -type f | sort)
if [[ -z "$SO_FILES" ]]; then
echo "No shared libraries found in packed universal2 wheel"
exit 1
fi
for so in $SO_FILES; do
ARCHS=$(lipo -archs "$VERIFY_DIR/$so")
echo "$so: $ARCHS"
if [[ "$ARCHS" != *arm64* || "$ARCHS" != *x86_64* ]]; then
echo "Missing expected architectures for $so"
exit 1
fi
done
- name: Upload universal2 wheel
uses: actions/upload-artifact@v7
with:
name: pyfory-wheels-native-macos-universal2-${{ matrix.python-version }}
path: dist/*.whl