-
Notifications
You must be signed in to change notification settings - Fork 23
234 lines (221 loc) · 7.6 KB
/
dist_publish.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
name: Python wheels (& publish)
on:
push:
branches:
- master
pull_request:
release:
types: [created]
jobs:
build_llvm_win:
name: Build LLVM release for Windows
runs-on: windows-latest
steps:
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v2
with:
path: llvm/install
# TODO: would be really better to add the hash of the LLVM commit cloned
# TODO: add "14.16" as a variable easy to replace
key: ${{ runner.os }}-llvm-release-13-msvc1416
- name: Get LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: 'llvm/llvm-project'
ref: 'release/13.x'
path: 'llvm'
- uses: ilammy/msvc-dev-cmd@v1
if: steps.cache-llvm.outputs.cache-hit != 'true'
with:
toolset: "14.16"
- name: Build LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
choco install ninja
mkdir llvm/build
mkdir llvm/install
cd llvm/build
cmake ../llvm -DLLVM_BUILD_EXAMPLES=OFF -DCLANG_ENABLE_ARCMT=OFF -DCLANG_ENABLE_STATIC_ANALYZER=OFF -DLLVM_BUILD_TOOLS=ON -DCLANG_BUILD_TOOLS=OFF -DLLVM_INSTALL_UTILS=ON -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang -DLLVM_ENABLE_BINDINGS=OFF -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/../install" -DLLVM_ENABLE_THREADS=OFF -DLLVM_ENABLE_ZLIB=OFF -G Ninja
ninja install
build_llvm_manylinux:
name: Build LLVM release for Linux
strategy:
matrix:
include:
- tag: "manylinux2010_x86_64"
docker_host: quay.io/pypa
- tag: "manylinux2010_i686"
docker_host: quay.io/pypa
- tag: "manylinux2014_aarch64_cross_x64"
docker_host: aguinet
runs-on: ubuntu-latest
steps:
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v2
with:
path: llvm/install
key: ${{ runner.os }}-llvm-release-13-${{ matrix.tag }}
- uses: actions/checkout@v2
if: steps.cache-llvm.outputs.cache-hit != 'true'
- name: Get LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: 'llvm/llvm-project'
ref: 'release/13.x'
path: 'llvm'
- name: Set up QEMU
if: matrix.tag == 'manylinux2014_aarch64_cross_x64' && steps.cache-llvm.outputs.cache-hit != 'true'
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: arm64
- name: Setup AArch64 environment
if: matrix.tag == 'manylinux2014_aarch64_cross_x64' && steps.cache-llvm.outputs.cache-hit != 'true'
run: |
echo "DOCKER_OPTS=--env CC=/opt/native/bin/clang --env CXX=/opt/native/bin/clang++ --env CMAKE_BIN=/opt/native/bin/cmake --env LDFLAGS=-fuse-ld=lld" >>$GITHUB_ENV
- name: Build LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
docker run $DOCKER_OPTS -v $GITHUB_WORKSPACE:/pwd "${{ matrix.docker_host }}/${{ matrix.tag }}" /bin/bash /pwd/ci/build_llvm_manylinux.sh /pwd/llvm
build_manylinux:
runs-on: ubuntu-latest
needs: build_llvm_manylinux
# Split into multiple jobs to speed up the process. Let's compile two
# Python versions per job.
strategy:
matrix:
tag:
- "manylinux2010_x86_64"
- "manylinux2010_i686"
- "manylinux2014_aarch64_cross_x64"
py_vers:
- "cp36-cp36m cp37-cp37m"
- "cp38-cp38 cp39-cp39"
- "cp310-cp310"
exclude:
- tag: "manylinux2014_aarch64_cross_x64"
py_vers: "cp310-cp310"
env:
PY_VERS: ${{ matrix.py_vers }}
steps:
- uses: actions/checkout@v2
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v2
with:
path: llvm/install
key: Linux-llvm-release-13-${{ matrix.tag }}
- name: Set up QEMU
if: matrix.tag == 'manylinux2014_aarch64_cross_x64'
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: arm64
- name: Setup AArch64 environment
if: matrix.tag == 'manylinux2014_aarch64_cross_x64'
run: |
echo "DOCKER_OPTS=--env CC=/opt/native/bin/clang --env CXX=/opt/native/bin/clang++ --env CMAKE_BIN=/opt/native/bin/cmake --env LDFLAGS=-fuse-ld=lld" >>$GITHUB_ENV
- name: Build wheels & tests
working-directory: bindings/python
run: |
[[ ${{ matrix.tag}} == "manylinux2014_aarch64_cross_x64" ]] && DOCKER_ROOT=aguinet || DOCKER_ROOT=quay.io/pypa
docker run $DOCKER_OPTS -v $GITHUB_WORKSPACE:/pwd "$DOCKER_ROOT/${{ matrix.tag }}" /bin/bash /pwd/ci/build_wheels_manylinux.sh /pwd /pwd/llvm/install $PY_VERS
- uses: actions/upload-artifact@v1
with:
name: pydffi-wheels
path: bindings/python/wheelhouse/
build_osxwin:
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
os:
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
needs: build_llvm_win
steps:
- uses: actions/checkout@v2
- uses: ilammy/msvc-dev-cmd@v1
with:
toolset: "14.16"
if: runner.os == 'Windows'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache LLVM
if: runner.os == 'Windows'
id: cache-llvm
uses: actions/cache@v2
with:
path: llvm/install
key: ${{ runner.os }}-llvm-release-13-msvc1416
- name: Python dependencies
run: |
pip install wheel
- name: Install Windows dependencies
run: |
choco install ninja
echo LLVM_CONFIG=%GITHUB_WORKSPACE%/llvm/install/bin/llvm-config.exe >> %GITHUB_ENV%
echo MSSdk=1 >> %GITHUB_ENV%
echo DISTUTILS_USE_SDK=1 >> %GITHUB_ENV%
if: runner.os == 'Windows'
shell: cmd
- name: Install OSX dependencies
run: |
brew install cmake ninja
sudo $CONDA/bin/conda install -c conda-forge llvmdev==13.0.0 clangdev==13.0.0
echo "LLVM_CONFIG=$CONDA/bin/llvm-config" >> $GITHUB_ENV
if: runner.os == 'macOS'
- name: Build wheel
working-directory: bindings/python
run: |
python ./setup.py bdist_wheel
- name: Install Windows
if: runner.os == 'Windows'
working-directory: bindings/python
run: |
pip install (get-item ./dist/*.whl).FullName
- name: Install OSX
if: runner.os == 'macOS'
working-directory: bindings/python
run: |
pip install dist/*.whl
- name: Tests
run: |
# Do not set bindings/python as the working directory to make sure we
# use the generated wheel for tests.
pip install six purectypes==0.2
python -m unittest discover bindings/python/tests
- uses: actions/upload-artifact@v1
with:
name: pydffi-wheels
path: bindings/python/dist/
publish:
if: github.event.release
runs-on: ubuntu-latest
needs: [build_manylinux, build_osxwin]
steps:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install twine
- uses: actions/download-artifact@v1
with:
name: pydffi-wheels
path: wheelhouse
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload wheelhouse/*.whl