This repository has been archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipeline.yml
357 lines (342 loc) · 14.3 KB
/
azure-pipeline.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
trigger:
branches:
include:
- branch-for-*
pr: none
variables:
# Name of the service connection set up in Azure Pipelines, used to upload
# release artifacts to GitHub. Set to false to disable.
GH_CONNECTION: wheelwright
REPO_DIR: checkout
ARTIFACT_NAME: artifacts
LINUX_TARGET: /io
BUILD_DEPENDS: "-Ur checkout/requirements.txt"
TEST_DEPENDS: "-Ur checkout/requirements.txt"
PLAT: x86_64
UNICODE_WIDTH: 32
HOMEBREW_NO_AUTO_UPDATE: 1
MANYLINUX_VERSION: 2014
jobs:
- job: "sdist"
pool:
vmImage: 'ubuntu-20.04'
variables:
python.version: '3.8'
CC: gcc-9
CXX: g++-9
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
# This is messy, but the most convenient way to turn a JSON file into env
# variables without requiring extra dependencies. The "##vso" stuff makes the
# variables available to later steps.
#
# We're also setting py35 as an output variable to be used in the next
# step and its build matrix. This lets us avoid having to add complex
# conditions to each build step (as there seems to be no convenient way to
# just skip the whole rest of the pipeline).
- bash: |
eval $(python -c "
import json; import sys
with open('build-spec.json') as f: spec = json.load(f)
release_id = spec.get('upload-to', {}).get('release-id', '').replace('/', '-')
build_py35 = spec.get('options', {}).get('py35', '')
skip_tests = spec.get('options', {}).get('skip_tests', '')
universal = spec.get('options', {}).get('universal', '')
build_constraints = spec.get('options', {}).get('build_constraints', '')
sys.stdout.write('BUILD_SPEC_CLONE_URL={}\n'.format(spec.get('clone-url')))
sys.stdout.write('BUILD_SPEC_COMMIT={}\n'.format(spec.get('commit')))
sys.stdout.write('BUILD_SPEC_PACKAGE_NAME={}\n'.format(spec.get('package-name')))
sys.stdout.write('BUILD_SPEC_RELEASE_ID={}\n'.format(release_id))
sys.stdout.write('BUILD_SPEC_PY35={}\n'.format(build_py35))
sys.stdout.write('BUILD_SPEC_SKIP_TESTS={}\n'.format(skip_tests))
sys.stdout.write('BUILD_SPEC_UNIVERSAL={}\n'.format(universal))
sys.stdout.write('BUILD_SPEC_BUILD_CONSTRAINTS={}\n'.format(build_constraints))")
echo "##vso[task.setvariable variable=clone_url]$BUILD_SPEC_CLONE_URL"
echo "##vso[task.setvariable variable=commit]$BUILD_SPEC_COMMIT"
echo "##vso[task.setvariable variable=package_name]$BUILD_SPEC_PACKAGE_NAME"
echo "##vso[task.setvariable variable=checkout]$REPO_DIR"
echo "##vso[task.setvariable variable=release_tag]$BUILD_SPEC_RELEASE_ID"
echo "##vso[task.setvariable variable=py35;isOutput=true]$BUILD_SPEC_PY35"
echo "##vso[task.setvariable variable=skip_tests;isOutput=true]$BUILD_SPEC_SKIP_TESTS"
echo "##vso[task.setvariable variable=universal;isOutput=true]$BUILD_SPEC_UNIVERSAL"
echo "##vso[task.setvariable variable=build_constraints;isOutput=true]$BUILD_SPEC_BUILD_CONSTRAINTS"
name: set_variables
displayName: 'Set variables'
- script: |
export CC=$(CC)
export CXX=$(CXX)
git clone $(clone_url) $(checkout)
cd $(checkout)
git checkout $(commit)
python -m pip install -U pip setuptools
python -m pip install -r requirements.txt
python setup.py sdist
displayName: 'Install and build sdist'
- script: |
cd $(checkout)
export CC=$(CC)
export CXX=$(CXX)
python -m pip install -U wheel
python setup.py bdist_wheel
displayName: 'Build universal wheel'
condition: eq(variables['set_variables.universal'], 'True')
- bash: |
cd $(Build.SourcesDirectory)/$(checkout)
SDIST=$(python -c "import os;print(os.listdir('./dist')[0])" 2>&1)
rm -rf $(package_name)
python -m pip freeze > installed.txt
python -m pip uninstall -y -r installed.txt
python -m pip install dist/$SDIST
pip install -r requirements.txt
condition: ne(variables['set_variables.skip_tests'], 'True')
displayName: 'Install from sdist & run tests'
- task: CopyFiles@2
inputs:
contents: '$(checkout)/dist/**'
targetFolder: $(Build.ArtifactStagingDirectory)
flattenFolders: true
displayName: 'Copy sdist'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: '$(ARTIFACT_NAME)'
displayName: 'Publish sdist to artifacts'
- task: GitHubRelease@0
inputs:
gitHubConnection: '$(GH_CONNECTION)'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
tagSource: manual
tag: '$(release_tag)'
addChangeLog: false
assetUploadMode: replace
assets: '$(Build.ArtifactStagingDirectory)/*'
displayName: 'Upload to GitHub release'
- job: 'wheels'
dependsOn: 'sdist'
condition: not(eq(dependencies.sdist.outputs['set_variables.universal'], 'True'))
continueOnError: true
strategy:
matrix:
Python36Linux:
imageName: 'ubuntu-16.04'
python.version: '3.6'
os: linux
Python36Windows:
imageName: 'vs2017-win2016'
python.version: '3.6'
os: win
Python36Mac:
imageName: 'macos-10.15'
python.version: '3.6'
os: osx
Python37Linux:
imageName: 'ubuntu-16.04'
python.version: '3.7'
os: linux
Python37Windows:
imageName: 'vs2017-win2016'
python.version: '3.7'
os: win
Python37Mac:
imageName: 'macos-10.15'
python.version: '3.7'
os: osx
Python38Linux:
imageName: 'ubuntu-16.04'
python.version: '3.8'
os: linux
Python38Windows:
imageName: 'vs2017-win2016'
python.version: '3.8'
os: win
Python38Mac:
imageName: 'macos-10.15'
python.version: '3.8'
os: osx
maxParallel: 4
pool:
vmImage: $(imageName)
variables:
py35: $[ dependencies.sdist.outputs['set_variables.py35'] ]
steps:
# This could probably be done more elegantly. Comparison happens here so we
# can use the value of the py35 variable and assign a variable "active" that's
# available to all subsequent build steps in the pipeline
- bash: |
BUILD35=0; [ "$(py35)" == "True" ] && BUILD35=1
echo "Build Python 3.5:" $BUILD35
IS35=0; [ "$(python.version)" == "3.5" ] && IS35=1
echo "Is Python 3.5:" $IS35
ACTIVE=$(( IS35 && BUILD35 || ! IS35 ? 1 : 0 ))
echo "Build active:" $ACTIVE
echo "##vso[task.setvariable variable=active]$ACTIVE"
displayName: 'Set status'
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
condition: eq(variables['active'], 1)
- script: git submodule update --init --recursive
condition: eq(variables['active'], 1)
displayName: 'Set up multibuild'
# This is gettext needed for envsubst on osx =/
- script: |
brew install gettext
brew link --force gettext
condition: and(eq(variables['os'], 'osx'), eq(variables['active'], 1))
displayName: 'Before install (Mac)'
- script: |
SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
python -m pip install -U pip setuptools wheel virtualenv
condition: and(eq(variables['os'], 'win'), eq(variables['active'], 1))
displayName: 'Before install (Windows)'
# This is messy, but the most convenient way to turn a JSON file into env
# variables without requiring extra dependencies. The "##vso" stuff makes the
# variables available to later steps.
- bash: |
eval $(python -c "
import json; import sys
with open('build-spec.json') as f: spec = json.load(f)
release_id = spec.get('upload-to', {}).get('release-id', '').replace('/', '-')
use_llvm = spec.get('options', {}).get('llvm', '')
build_constraints = spec.get('options', {}).get('build_constraints', '')
sys.stdout.write('BUILD_SPEC_CLONE_URL={}\n'.format(spec.get('clone-url')))
sys.stdout.write('BUILD_SPEC_COMMIT={}\n'.format(spec.get('commit')))
sys.stdout.write('BUILD_SPEC_PACKAGE_NAME={}\n'.format(spec.get('package-name')))
sys.stdout.write('BUILD_SPEC_RELEASE_ID={}\n'.format(release_id))
sys.stdout.write('BUILD_SPEC_LLVM={}\n'.format(use_llvm))
sys.stdout.write('BUILD_SPEC_BUILD_CONSTRAINTS={}\n'.format(build_constraints))")
echo "##vso[task.setvariable variable=clone_url]$BUILD_SPEC_CLONE_URL"
echo "##vso[task.setvariable variable=package_name]$BUILD_SPEC_PACKAGE_NAME"
echo "##vso[task.setvariable variable=commit]$BUILD_SPEC_COMMIT"
echo "##vso[task.setvariable variable=release_tag]$BUILD_SPEC_RELEASE_ID"
echo "##vso[task.setvariable variable=checkout]$REPO_DIR"
echo "##vso[task.setvariable variable=llvm]$BUILD_SPEC_LLVM"
echo "##vso[task.setvariable variable=build_constraints]$BUILD_SPEC_BUILD_CONSTRAINTS"
echo "##vso[build.updatebuildnumber]$BUILD_SPEC_RELEASE_ID"
condition: eq(variables['active'], 1)
displayName: 'Set variables'
- script: |
pip install virtualenv
git clone $(clone_url) $(checkout)
export BUILD_COMMIT=$(commit)
export PACKAGE_NAME=$(package_name)
cat config.sh.template | envsubst > config.sh
condition: and(or(eq(variables['os'], 'osx'), eq(variables['os'], 'linux')), eq(variables['active'], 1))
displayName: 'Install (Mac / Linux)'
# This is hard-coded in the Docker scripts for Linux
- task: CopyFiles@2
inputs:
contents: '/**'
targetFolder: $LINUX_TARGET
condition: and(eq(variables['os'], 'linux'), eq(variables['active'], 1))
displayName: 'Copy multibuild files (Linux)'
- script: |
export BUILD_DEPENDS="$BUILD_DEPENDS -c checkout/build-constraints.txt"
condition: and(or(eq(variables['os'], 'osx'), eq(variables['os'], 'linux')), eq(variables['active'], 1), eq(variables['build_constraints'], 'True'))
displayName: 'Set dependencies with constraints (Mac / Linux)'
- script: |
[ "$(build_constraints)" == "True" ] && export BUILD_DEPENDS="$BUILD_DEPENDS -c checkout/build-constraints.txt"
echo "BUILD_DEPENDS:" $(BUILD_DEPENDS)
export MB_ML_VER=$(MANYLINUX_VERSION)
export MB_PYTHON_VERSION=$(python.version)
export TRAVIS_PYTHON_VERSION=$(python.version)
export TRAVIS_OS_NAME=$(os)
export BUILD_COMMIT=$(commit)
source $(Build.SourcesDirectory)/multibuild/common_utils.sh
source $(Build.SourcesDirectory)/multibuild/travis_steps.sh
before_install
clean_code $(checkout) $(commit)
export CONFIG_PATH=$LINUX_TARGET/config.sh
export MULTIBUILD_DIR=multibuild
build_wheel $(checkout) $PLAT
install_run $PLAT
condition: and(or(eq(variables['os'], 'osx'), eq(variables['os'], 'linux')), eq(variables['active'], 1))
displayName: 'Build wheel (Mac / Linux)'
- script: choco install llvm
condition: and(eq(variables['os'], 'win'), eq(variables['llvm'], 'true'), eq(variables['active'], 1))
displayName: 'Install LLVM if needed (Windows)'
# The env variables are needed to compile things like Blis
- script: |
set "PATH=C:\Program Files\LLVM\bin;%PATH%"
set "INCLUDE=%$VC_INCLUDEPATH%"
git clone $(clone_url) $(checkout)
cd $(checkout)
git checkout $(commit)
condition: and(eq(variables['os'], 'win'), eq(variables['active'], 1))
displayName: 'Check out and set up (Windows)'
- script: |
cd $(checkout)
python -m pip install -Ur requirements.txt
condition: and(eq(variables['os'], 'win'), eq(variables['active'], 1), eq(variables['build_constraints'], 'False'))
displayName: 'Install dependencies without constraints (Windows)'
- script: |
cd $(checkout)
python -m pip install -Ur requirements.txt -c build-constraints.txt
condition: and(eq(variables['os'], 'win'), eq(variables['active'], 1), eq(variables['build_constraints'], 'True'))
displayName: 'Install dependencies with constraints (Windows)'
# The env variables are needed to compile things like Blis
- script: |
cd $(checkout)
python setup.py bdist_wheel
condition: and(eq(variables['os'], 'win'), eq(variables['active'], 1))
displayName: 'Build wheel (Windows)'
# Temporary workaround, see: https://github.com/pypa/pip/issues/6951
- task: PythonScript@0
inputs:
scriptSource: inline
script: |
import os
wheel_file = os.listdir('./dist')[0]
wheel_path = os.path.join('./dist', wheel_file)
mod_wheel_path = wheel_path.replace("cp38m-win", "cp38-win")
mod_wheel_path = mod_wheel_path.replace("cp39m-win", "cp39-win")
os.rename(wheel_path, mod_wheel_path)
print(os.listdir('./dist'))
failOnStderr: true
workingDirectory: '$(Build.SourcesDirectory)/$(checkout)'
condition: and(eq(variables['os'], 'win'), or(eq(variables['python.version'], '3.8'), eq(variables['python.version'], '3.9')), eq(variables['active'], 1))
displayName: Fix wheel name (Windows, Python 3.8)
- bash: |
cd $(checkout)
WHEEL=$(python -c "import os;print(os.listdir('./dist')[0])" 2>&1)
pip install dist/$WHEEL
rm -rf $(package_name)
condition: and(eq(variables['os'], 'win'), eq(variables['active'], 1))
displayName: 'Test wheel (Windows)'
- task: CopyFiles@2
inputs:
contents: 'checkout/dist/**'
targetFolder: $(Build.ArtifactStagingDirectory)
flattenFolders: true
condition: and(eq(variables['os'], 'win'), eq(variables['active'], 1))
displayName: 'Copy wheel (Windows)'
- task: CopyFiles@2
inputs:
contents: 'wheelhouse/**'
targetFolder: $(Build.ArtifactStagingDirectory)
flattenFolders: true
condition: and(or(eq(variables['os'], 'osx'), eq(variables['os'], 'linux')), eq(variables['active'], 1))
displayName: 'Copy wheel (Mac / Linux)'
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: '$(ARTIFACT_NAME)'
condition: eq(variables['active'], 1)
displayName: 'Publish artifact'
- task: GitHubRelease@0
inputs:
gitHubConnection: '$(GH_CONNECTION)'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
tagSource: manual
tag: '$(release_tag)'
addChangeLog: false
assetUploadMode: replace
assets: '$(Build.ArtifactStagingDirectory)/*'
condition: and(not(eq(variables['GH_CONNECTION'], 'false')), eq(variables['active'], 1))
displayName: 'Upload to GitHub release'