-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path_build-python-wheel-extension.yml
More file actions
220 lines (187 loc) · 6.14 KB
/
_build-python-wheel-extension.yml
File metadata and controls
220 lines (187 loc) · 6.14 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
name: Build wheel and sdist for an extension Python package
on:
workflow_call:
inputs:
project:
description: 'Name of the project to build'
default: 'PROJECT_NAME'
required: true
type: string
python_version:
description: 'Python versions to use for building'
required: true
type: string
jobs:
build_sdist:
defaults:
run:
shell: bash -l {0}
name: Build sdist
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Initialize miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: sdist
channels: conda-forge
auto-update-conda: true
auto-activate-base: false
python-version: ${{ inputs.python_version }}
- name: Conda config
run: >-
conda config --set always_yes yes
--set changeps1 no
- name: Build sdist
run: |
conda install --file requirements/conda.txt
pip install --upgrade build
python -m build --sdist
- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: ./dist/*.tar.gz
build-wheel:
needs: [build_sdist]
defaults:
run:
shell: bash -l {0}
name: cibw-wheels-${{ matrix.python }}-${{ matrix.buildplat }}
runs-on: ${{ matrix.buildplat }}
strategy:
fail-fast: false
matrix:
buildplat:
- ubuntu-latest
- macos-latest
- macos-15-intel
- windows-latest
python: ${{ fromJSON(inputs.python_version || '["3.12", "3.13", "3.14"]') }}
steps:
- name: Check out
uses: actions/checkout@v4
- name: Debug python version source
run: |
if [ -n "${{ inputs.python_version }}" ]; then
echo "Python versions obtained dynamically from workflow_call input:"
echo " ${{ inputs.python_version }}"
else
echo "python_version input empty or missing. Falling back to default:"
echo " [\"3.12\", \"3.13\", \"3.14\"]"
fi
echo "Resolved matrix value for this job:"
echo " ${{ matrix.python }}"
- name: Initialize miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: build
channels: conda-forge
auto-update-conda: true
auto-activate-base: false
python-version: ${{ matrix.python }}
- name: Conda config
run: >-
conda config --set always_yes yes
--set changeps1 no
- name: Install requirements and build wheels
run: |
conda install --file requirements/conda.txt
conda install --file requirements/pip.txt
pip install --upgrade build
python -m pip wheel --no-deps --wheel-dir ./dist .
- name: Repair wheels
if: matrix.buildplat == 'ubuntu-latest'
run: |
conda install auditwheel patchelf
LD_LIBRARY_PATH=$CONDA_PREFIX/lib auditwheel repair dist/*.whl -w dist/
set -euo pipefail
project="${{ inputs.project }}"
project_path="${project//./\/}"
project_pkg="${project//./_}"
dist_dir="$(pwd)/dist"
for whl in "$dist_dir"/*manylinux*.whl; do
echo "Patching $whl"
tmp=$(mktemp -d)
unzip -q "$whl" -d "$tmp"
libsdir="$tmp/${project_pkg}.libs"
declare -A vend_map
for f in "$libsdir"/*.so*; do
base=$(basename "$f")
if [[ $base =~ ^(.+)-([0-9a-f]{8})(\.so.*)$ ]]; then
real="${BASH_REMATCH[1]}${BASH_REMATCH[3]}"
else
real="$base"
fi
vend_map["$base"]="$real"
done
find "$tmp/$project_path" -type f -name "*.so" | while read -r so; do
for vend in "${!vend_map[@]}"; do
real=${vend_map[$vend]}
echo " replace-needed $vend → $real in $so"
patchelf --replace-needed "$vend" "$real" "$so"
done
if [[ "$project" == *.* ]]; then
rpath='$ORIGIN/../../../../'
else
rpath='$ORIGIN/../../../'
fi
echo " set-rpath in $so"
patchelf --set-rpath "$rpath" "$so"
done
rm -f "$libsdir"/*.so*
rm -f "$whl"
( cd "$tmp" && zip -q -FS -r "$whl" . )
rm -rf "$tmp"
done
echo "Patch done!"
rm dist/*-linux_*.whl
- name: Upload wheels to GitHub
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.python }}-${{ matrix.buildplat }}.whl
path: ./dist/*.whl
test-wheels:
needs: [build-wheel]
defaults:
run:
shell: bash -l {0}
name: test-wheels-${{ matrix.python }}-${{ matrix.buildplat }}
runs-on: ${{ matrix.buildplat }}
strategy:
fail-fast: false
matrix:
buildplat:
- ubuntu-latest
- macos-latest
- macos-15-intel
- windows-latest
python: ${{ fromJSON(inputs.python_version) }}
steps:
- name: Check out
uses: actions/checkout@v4
- name: Download wheels
uses: actions/download-artifact@v4
with:
name: ${{ matrix.python }}-${{ matrix.buildplat }}.whl
path: ./dist
- name: Initialize miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: test
channels: conda-forge
auto-update-conda: true
auto-activate-base: false
python-version: ${{ matrix.python }}
- name: Conda config
run: >-
conda config --set always_yes yes
--set changeps1 no
- name: Install requirements
run: |
conda install --file requirements/conda.txt
conda install --file requirements/tests.txt
- name: Install wheel and test
run: |
pip install ./dist/*.whl
pytest