forked from Chia-Network/bls-signatures
-
Notifications
You must be signed in to change notification settings - Fork 15
175 lines (158 loc) · 6.47 KB
/
build-wheels.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
name: Build wheels
on: [push, pull_request]
jobs:
build_wheels:
name: Build wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- name: Cancel previous runs on the same branch
if: ${{ github.ref != 'refs/heads/main' }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'
- name: Lint source with flake8
run: |
python -m pip install --upgrade pip
pip install flake8
flake8 src setup.py python-bindings python-impl
- name: Lint source with mypy
run: |
pip install mypy
mypy --config-file mypi.ini python-bindings python-impl
- name: Build source distribution with Ubuntu-latest
if: startsWith(matrix.os, 'ubuntu')
run: |
pip install build
python -m build --sdist --outdir dist .
- name: Build ${{ matrix.os }} wheels and test
uses: joerick/[email protected]
with:
output-dir: dist
env:
CIBW_BUILD_VERBOSITY_MACOS: 0
CIBW_BUILD_VERBOSITY_LINUX: 0
CIBW_BUILD_VERBOSITY_WINDOWS: 0
# Python 3.7 and 3.8
CIBW_BUILD: cp37-* cp38-* cp39-*
CIBW_SKIP: '*-manylinux_i686 *-win32'
CIBW_TEST_REQUIRES: pytest
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2010
CIBW_ENVIRONMENT_LINUX: "PATH=/project/cmake-3.17.3-Linux-`uname -m`/bin:$PATH"
CIBW_BEFORE_ALL_LINUX: >
yum -y install epel-release
&& yum -y install lzip
&& curl -L https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3-Linux-`uname -m`.sh > cmake.sh
&& yes | sh cmake.sh | cat
&& rm -f /usr/bin/cmake && hash -r
&& which cmake
&& cmake --version
&& echo "curling GMP 6.2.1"
&& curl -L https://gmplib.org/download/gmp/gmp-6.2.1.tar.lz | lzip -dc | tar x
&& echo "Patching GMP for lzcnt"
&& cp contrib/gmp-patch-6.2.1/longlong.h gmp-6.2.1/
&& cp contrib/gmp-patch-6.2.1/compat.c gmp-6.2.1/
&& echo "Building GMP"
&& cd gmp-6.2.1 && ./configure --enable-fat
&& make && make install && cd .. && rm -rf gmp-6.2.1
&& curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz | tar xz
&& cd libsodium-stable && ./configure --with-pic="yes"
&& make && make install && cd .. && rm -rf libsodium-stable
CIBW_BEFORE_BUID_LINUX: >
python -m pip install --upgrade pip
CIBW_ENVIRONMENT_MACOS: "MACOSX_DEPLOYMENT_TARGET=10.14"
# GH hosted MacOS runner has gmp and libsodium natively
# CIBW_ARCHS_MACOS: x86_64 arm64 universal2
CIBW_ARCHS_MACOS: x86_64
CIBW_TEST_SKIP: '*_arm64 *_universal2:arm64'
CIBW_BEFORE_BUILD_MACOS: >
python -m pip install --upgrade pip
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
pip uninstall -y delocate
&& pip install git+https://github.com/Chia-Network/delocate.git
&& delocate-listdeps {wheel}
&& delocate-wheel -v {wheel}
&& cp {wheel} {dest_dir}
CIBW_BEFORE_ALL_WINDOWS: >
curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip > libsodium-1.0.18-stable-msvc.zip
&& 7z x libsodium-1.0.18-stable-msvc.zip
&& git clone https://github.com/Chia-Network/relic_ietf_64.git
&& ls -l relic_ietf_64
&& git clone https://github.com/Chia-Network/mpir_gc_x64.git
&& ls -l mpir_gc_x64
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
pip uninstall -y delocate
&& pip install git+https://github.com/Chia-Network/delocate.git
&& delocate-wheel -v -i mpir_gc_x64/mpir.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_gc.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_broadwell.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_broadwell_avx.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_bulldozer.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_haswell.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_piledriver.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_sandybridge.dll {wheel}
&& delocate-wheel -v -i mpir_gc_x64/mpir_skylake_avx.dll {wheel}
&& cp {wheel} {dest_dir} && ls -l {dest_dir}
# CIBW_ENVIRONMENT_WINDOWS: ""
CIBW_TEST_COMMAND: pytest -v {project}/python-bindings/test.py
- name: Create sha256 wheel hashes
if: startsWith(runner.os, 'linux') || startsWith(runner.os, 'windows')
run: |
mkdir hashes
cd ./dist
sha256sum *
sha256sum * > ../hashes/wheel-sha256.txt
- name: Create sha256 wheel hashes - MacOS
if: startsWith(runner.os, 'macos')
run: |
mkdir hashes
cd ./dist
shasum -a 256 *
shasum -a 256 * > ../hashes/blspy-wheels-sha256.txt
- name: Upload hashes
uses: actions/upload-artifact@v2
with:
name: blspy-hashes
path: ./hashes
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./dist
- name: Test for secrets access
id: check_secrets
shell: bash
run: |
unset HAS_SECRET
if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi
echo ::set-output name=HAS_SECRET::${HAS_SECRET}
env:
SECRET: "${{ secrets.test_pypi_password }}"
- name: Install twine
run: pip install twine
- name: Publish distribution to PyPI
if: startsWith(github.event.ref, 'refs/tags') && steps.check_secrets.outputs.HAS_SECRET
env:
TWINE_USERNAME: __token__
TWINE_NON_INTERACTIVE: 1
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: twine upload --non-interactive --skip-existing --verbose 'dist/*'
- name: Publish distribution to Test PyPI
if: steps.check_secrets.outputs.HAS_SECRET
env:
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
TWINE_USERNAME: __token__
TWINE_NON_INTERACTIVE: 1
TWINE_PASSWORD: ${{ secrets.test_pypi_password }}
run: twine upload --non-interactive --skip-existing --verbose 'dist/*'