-
Notifications
You must be signed in to change notification settings - Fork 1
401 lines (376 loc) · 17.2 KB
/
lint-test-build-upload.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
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
name: lint-test-build-upload
on:
push
jobs:
manylinux:
container: quay.io/pypa/manylinux2014_x86_64
name: "Python ${{ matrix.PYTHON }} on manylinux2014"
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v2
-
name: "Install Python."
run: |
yum -y install wget libffi-devel patchelf
/opt/python/${{ matrix.PYTHON }}/bin/python -m pip install virtualenv
/opt/python/${{ matrix.PYTHON }}/bin/python -m virtualenv .venv
-
name: "Install Python dependencies for build process."
run: ".venv/bin/pip install -U pip setuptools wheel build"
-
name: "Download mcl source tree archive and extract it."
run: |
wget https://github.com/herumi/mcl/archive/refs/tags/v1.61.tar.gz
tar -xvzf *.tar.gz
-
name: "Build wheel file."
run: |
# Compile platform-dependent binaries.
cd mcl*
make
ls lib
cd ..
# Remove prebuilt binaries (if any are leftover from an old build).
rm -f mclbn256/libmclbn256.*
rm -f mclbn256/lib/libmcl.*
# Copy binaries into Python module.
cp mcl-*/lib/libmclbn256.so mclbn256
cp mcl-*/lib/libmcl.so mclbn256/lib
#
# Allow relative linking of libmcl.so dependency (also likely unused, but changing a link is easier than deleting one)
#
echo "Files linked to from lib/libmcl.so"
patchelf --print-needed mclbn256/lib/libmcl.so # dependency has only standard system dependenciesendency (also likely unused, but changing a link is easier than deleting one)
echo "Files linked to from libmclbn256.so"
patchelf --print-needed mclbn256/libmclbn256.so # the BN254 build depends on lib/libmcl.so which may not be in any environment folder
echo "patching..."
patchelf --replace-needed lib/libmcl.so \$ORIGIN/lib/libmcl.so mclbn256/libmclbn256.so
echo "Files linked to from libmclbn256.so"
patchelf --print-needed mclbn256/libmclbn256.so # the lib/libmcl.so dependency should be relative now
echo "patching..."
patchelf --replace-needed libmcl.so \$ORIGIN/lib/libmcl.so mclbn256/libmclbn256.so
echo "Files linked to from libmclbn256.so"
patchelf --print-needed mclbn256/libmclbn256.so # the lib/libmcl.so dependency should be relative now
# echo "adding dependency...";#echo "patching..."
# patchelf --add-needed \$ORIGIN/lib/libmcl.so mclbn256/libmclbn256.so
# # patchelf --add-needed \$ORIGIN/libmcl.so mclbn256/libmclbn256.so
echo "adding dependency...";#echo "patching..."
patchelf --add-needed lib/libmcl.so mclbn256/libmclbn256.so
patchelf --add-rpath \$ORIGIN/ mclbn256/libmclbn256.so
# patchelf --add-rpath . mclbn256/libmclbn256.so
echo "Files linked to from libmclbn256.so"
patchelf --print-needed mclbn256/libmclbn256.so # the lib/libmcl.so dependency should be relative now
# # Build
# .venv/bin/python -m build
# mkdir tmpwheelhouse
# mv dist/mclbn*.whl tmpwheelhouse
mkdir lib; cp mcl-*/lib/libmcl.so lib
# mkdir tmpwheelhouse/lib; cp mcl-*/lib/libmcl.so tmpwheelhouse/lib
# cp mcl-*/lib/libmcl.so /usr/local/bin
# auditwheel repair tmpwheelhouse/mclbn*.whl -w wheelhouse/
# # mkdir wheelhouse
# # mv dist/mclbn*.whl wheelhouse
# -
# name: "Test wheel installation."
# run: |
# ls wheelhouse
# unzip -Zl wheelhouse/*.whl
# # ls -R wheelhouse
# .venv/bin/pip install -f wheelhouse --no-index mclbn256
-
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
name: "Lint and test module (and compiled MCl shared library files)."
run: |
.venv/bin/python -c "import mclbn256; mclbn256.mclbn256.assert_bilinearity(); mclbn256.mclbn256.assert_serializable(); print('pass')"
#.venv/bin/pip install -U pylint coverage coveralls nose
#.venv/bin/python -m pylint mclbn256 # Check against linting rules.
#.venv/bin/python mclbn256/mclbn256.py -v # Run doctests.
#.venv/bin/python -m nose --cover-erase # Test using nose.
#.venv/bin/python -m coveralls --service=github # Submit to coveralls.
# -
# name: "Upload wheel file."
# run: |
# mkdir mclbn-wheelhouse
# mv wheelhouse/mclbn*.whl mclbn-wheelhouse/
# -
# uses: actions/upload-artifact@v1
# with:
# name: "mclbn256-0.3.3-manylinux1-${{ matrix.PYTHON }}"
# path: mclbn-wheelhouse/
strategy:
matrix:
PYTHON:
- cp37-cp37m
- cp38-cp38
- cp39-cp39
- cp310-cp310
- cp311-cp311
macos:
name: "Python ${{ matrix.PYTHON.VERSION }} for ABI ${{ matrix.PYTHON.ABI_VERSION }} on macOS"
runs-on: macOS-latest
steps:
-
uses: actions/checkout@v2
-
env:
PYTHON_DOWNLOAD_URL: "${{ matrix.PYTHON.DOWNLOAD_URL }}"
name: "Install Python."
run: |
curl "$PYTHON_DOWNLOAD_URL" -o python.pkg
sudo installer -pkg python.pkg -target /
${{ matrix.PYTHON.BIN_PATH }} -m pip install -U virtualenv
${{ matrix.PYTHON.BIN_PATH }} -m virtualenv venv
-
name: "Install Python dependencies for build process."
run: "venv/bin/pip install -U pip setuptools wheel build"
-
name: "Download MCl source tree archive and extract it."
run: |
wget https://github.com/herumi/mcl/archive/refs/tags/v1.61.tar.gz
tar -xvzf *.tar.gz
-
env:
PYTHON_VERSION: "${{ matrix.PYTHON.ABI_VERSION }}"
name: "Build wheel file."
run: |
# Compile platform-dependent binaries.
cd mcl*
make
ls lib
cd ..
# Remove prebuilt binaries (if any are leftover from an old build).
rm -f mclbn256/libmclbn256.*
rm -f mclbn256/lib/libmcl.*
# Copy binaries into Python module.
cp mcl-*/lib/libmclbn256.dylib mclbn256
cp mcl-*/lib/libmcl.dylib mclbn256/lib
# Allow relative linking of libmcl.dylib dependency (also likely unused, but changing a link is easier than deleting one)
otool -L mclbn256/lib/libmcl.dylib # dependency has only standard system dependencies
otool -L mclbn256/libmclbn256.dylib # the BN254 build depends on lib/libmcl.so which may not be in any environment folder
install_name_tool -change lib/libmcl.dylib @loader_path/lib/libmcl.dylib mclbn256/libmclbn256.dylib
# # Build
# venv/bin/python -m build
# mkdir wheelhouse
# mv dist/mclbn*.whl wheelhouse
# -
# name: "Test wheel installation."
# run: |
# ls wheelhouse
# unzip -Zl wheelhouse/*.whl
# # ls -R wheelhouse
# venv/bin/pip install .
# # venv/bin/pip install -f wheelhouse --no-index mclbn256
-
name: "Lint and test module (and compiled MCl shared library files)."
run: |
venv/bin/python -c "import mclbn256; mclbn256.mclbn256.assert_bilinearity(); mclbn256.mclbn256.assert_serializable(); print('pass')"
# venv/bin/pip install -U pip pylint coverage nose
# venv/bin/python -m pylint mclbn256 # Check against linting rules.
# venv/bin/python mclbn256/mclbn256.py -v # Run doctests.
# venv/bin/python -m nose --cover-erase # Test using nose.
# -
# name: "Upload wheel file."
# run: |
# mkdir mclbn-wheelhouse
# mv wheelhouse/mclbn*.whl mclbn-wheelhouse/
# -
# uses: actions/upload-artifact@v1
# with:
# name: "mclbn-0.3.3-macOS-11-amd-${{ matrix.PYTHON.VERSION }}"
# path: mclbn-wheelhouse/
strategy:
matrix:
PYTHON:
-
ABI_VERSION: "3.6"
BIN_PATH: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
DOWNLOAD_URL: "https://www.python.org/ftp/python/3.9.12/python-3.9.12-macos11.pkg"
VERSION: "3.9"
-
ABI_VERSION: "3.6"
BIN_PATH: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
DOWNLOAD_URL: "https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg"
VERSION: "3.10"
-
ABI_VERSION: "3.6"
BIN_PATH: /Library/Frameworks/Python.framework/Versions/3.11/bin/python3
DOWNLOAD_URL: "https://www.python.org/ftp/python/3.11.6/python-3.11.6-macos11.pkg"
VERSION: "3.11"
macos-arm:
name: "Python ${{ matrix.PYTHON.VERSION }} for ABI ${{ matrix.PYTHON.ABI_VERSION }} on macOS ARM"
runs-on: [self-hosted, macos, ARM64]
steps:
-
uses: actions/checkout@v2
-
env:
PYTHON_DOWNLOAD_URL: "${{ matrix.PYTHON.DOWNLOAD_URL }}"
name: "Install Python."
run: |
curl "$PYTHON_DOWNLOAD_URL" -o python.pkg
sudo installer -pkg python.pkg -target /
${{ matrix.PYTHON.BIN_PATH }} -m pip install -U virtualenv
${{ matrix.PYTHON.BIN_PATH }} -m virtualenv venv
-
name: "Install Python dependencies for build process."
run: "venv/bin/pip install -U pip setuptools wheel build"
-
name: "Download mcl source tree archive and extract it."
run: |
wget https://github.com/herumi/mcl/archive/refs/tags/v1.61.tar.gz
tar -xvzf *.tar.gz
-
env:
PYTHON_VERSION: "${{ matrix.PYTHON.ABI_VERSION }}"
name: "Build wheel file."
run: |
# Compile platform-dependent binaries.
cd mcl*
make
ls lib
cd ..
# Remove prebuilt binaries (if any are leftover from an old build).
rm -f mclbn256/libmclbn256.*
rm -f mclbn256/lib/libmcl.*
# Copy binaries into Python module.
cp mcl-*/lib/libmclbn256.dylib mclbn256
cp mcl-*/lib/libmcl.dylib mclbn256/lib
# Allow relative linking of libmcl.dylib dependency (also likely unused, but changing a link is easier than deleting one)
otool -L mclbn256/lib/libmcl.dylib # dependency has only standard system dependencies
otool -L mclbn256/libmclbn256.dylib # the BN254 build depends on lib/libmcl.so which may not be in any environment folder
install_name_tool -change lib/libmcl.dylib @loader_path/lib/libmcl.dylib mclbn256/libmclbn256.dylib
# # Build
# venv/bin/python -m build
# mkdir wheelhouse
# mv dist/mclbn*.whl wheelhouse
# -
# name: "Test wheel installation."
# run: |
# ls wheelhouse
# unzip -Zl wheelhouse/*.whl
# # ls -R wheelhouse
# venv/bin/pip install -f wheelhouse --no-index mclbn256
-
name: "Lint and test module (and compiled MCl shared library files)."
run: |
venv/bin/python -c "import mclbn256; mclbn256.mclbn256.assert_bilinearity(); mclbn256.mclbn256.assert_serializable(); print('pass')"
# venv/bin/pip install -U pip pylint coverage nose
# venv/bin/python -m pylint mclbn256 # Check against linting rules.
# venv/bin/python mclbn256/mclbn256.py -v # Run doctests.
#venv/bin/python -m nose --cover-erase # Test using nose. # mclbn256 0.2.0 has succeeded before but but errored at end [due to nose in 3.10 bug](https://github.com/nose-devs/nose/issues/1099)
# -
# name: "Upload wheel file."
# run: |
# mkdir mclbn-wheelhouse
# mv wheelhouse/mclbn*.whl mclbn-wheelhouse/
# -
# uses: actions/upload-artifact@v1
# with:
# name: "mclbn-0.3.3-macOS-arm-${{ matrix.PYTHON.VERSION }}"
# path: mclbn-wheelhouse/
strategy:
matrix:
PYTHON:
-
ABI_VERSION: "3.6"
BIN_PATH: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
DOWNLOAD_URL: "https://www.python.org/ftp/python/3.9.12/python-3.9.12-macos11.pkg"
VERSION: "3.9"
-
ABI_VERSION: "3.6"
BIN_PATH: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
DOWNLOAD_URL: "https://www.python.org/ftp/python/3.10.5/python-3.10.5-macos11.pkg"
VERSION: "3.10"
-
ABI_VERSION: "3.6"
BIN_PATH: /Library/Frameworks/Python.framework/Versions/3.11/bin/python3
DOWNLOAD_URL: "https://www.python.org/ftp/python/3.11.6/python-3.11.6-macos11.pkg"
VERSION: "3.11"
windows:
runs-on: windows-latest
strategy:
matrix:
WINDOWS:
- {ARCH: 'x86', MCL_ARCH: 'Win32', VS_ARCH: 'x86'}
- {ARCH: 'x64', MCL_ARCH: 'x64', VS_ARCH: 'amd64'}
PYTHON:
- {VERSION: "3.9", MCL_MSVC_VERSION: "v142", "USE_ABI3": "true", "ABI_VERSION": "cp36"}
- {VERSION: "3.10", MCL_MSVC_VERSION: "v142", "USE_ABI3": "true", "ABI_VERSION": "cp36"}
- {VERSION: "3.11", MCL_MSVC_VERSION: "v142", "USE_ABI3": "true", "ABI_VERSION": "cp36"}
name: "Python ${{ matrix.PYTHON.VERSION }} for ABI ${{ matrix.PYTHON.ABI_VERSION }} on Windows ${{ matrix.WINDOWS.ARCH }}"
steps:
- uses: actions/checkout@v2
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.10.0
- name: Install Python.
uses: actions/setup-python@v2.2.2
with:
python-version: ${{ matrix.PYTHON.VERSION }}
architecture: ${{ matrix.WINDOWS.ARCH }}
- name: Install Python dependencies for build process.
run: python -m pip install -U pip setuptools wheel cffi
shell: bash
- name: Download and extract mcl dynamic library file.
run: |
wget -O c:\msvc-mcl-v1.61.zip https://github.com/herumi/mcl/archive/refs/tags/v1.61.zip
Expand-Archive c:\msvc-mcl-v1.61.zip -DestinationPath d:\a\mclbn256\mclbn256
dir .
dir c:\
shell: powershell
- name: Add environment variables for MCl.
run: |
echo "INCLUDE=C:/MCl/include;$INCLUDE" >> $GITHUB_ENV
echo "LIB=C:/MCl/${{ matrix.WINDOWS.MCL_ARCH }}/release/${{ matrix.PYTHON.MCL_MSVC_VERSION }}/static;$LIB" >> $GITHUB_ENV
shell: bash
- name: Build DLL.
run: |
ls
cd mcl-*
ls
mklib dll
# mk -d test\bls12_test.cpp && bin\bls12_test.exe
cd ..
shell: cmd
- name: Build wheel file.
run: |
ls mcl-*/lib/
# echo
# echo
ls mcl-*/bin/
# echo
# echo
ls mclbn256/
cp mcl-*/bin/mclbn256.dll mclbn256/libmclbn256.dll
# mkdir wheelhouse
# # call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -no_logo -arch=${{ matrix.WINDOWS.VS_ARCH }}
# python setup.py bdist_wheel --py-limited-api=${{ matrix.PYTHON.ABI_VERSION }}
# # cp build/lib*/mclbn256/_MCL.pyd mclbn256
# ls dist
# mv dist/mclbn256*.whl wheelhouse
# ls wheelhouse
# shell: cmd
# - name: Test wheel installation.
# run: pip install -f wheelhouse mclbn256 --no-index
- name: Lint and test module (and compiled MCl shared library file).
run: |
# python -c "import mclbn256; mclbn256.mclbn256.assert_bilinearity(); mclbn256.mclbn256.assert_serializable(); print('pass')"
# python -c "exec(\"import mclbn256\n mclbn256.mclbn256.assert_bilinearity()\n mclbn256.mclbn256.assert_serializable()\n print('pass') \")"
# (echo "import mclbn256" ; echo "mclbn256.mclbn256.assert_bilinearity()" ; echo "mclbn256.mclbn256.assert_serializable()" ; echo "print('pass')") | python
# echo "import mclbn256\nmclbn256.mclbn256.assert_bilinearity()\nmclbn256.mclbn256.assert_serializable()\nprint('pass')" | python
# https://github.com/nthparty/mclbn256/actions/runs/6782373143/job/18434469291#step:10:62 Windows is impossible for me to test, because I don't know how to escape the test code in a string. None of the above will run without a shell-related error.
# python -m pip install -U pip pylint coverage nose
# python -m pylint mclbn256 # Check against linting rules.
# python mclbn256/mclbn256.py -v # Run doctests.
# python -m nose --cover-erase # Test using nose.
# - name: Upload wheel file.
# run: |
# mkdir mclbn256-wheelhouse
# move wheelhouse\mclbn256*.whl mclbn256-wheelhouse\
# # move mcl-*\* mclbn256-wheelhouse\
# # move mcl-*\lib\mclbn256.dll mclbn256-wheelhouse\
# - uses: actions/upload-artifact@v1
# with:
# name: "mclbn256-2.0.0-win-${{ matrix.WINDOWS.ARCH }}-${{ matrix.PYTHON.VERSION }}"
# path: mclbn256-wheelhouse