Skip to content

Commit 56dc66c

Browse files
committed
Build wheels for individual platforms/python versions
1 parent e6e60f7 commit 56dc66c

File tree

1 file changed

+228
-148
lines changed

1 file changed

+228
-148
lines changed

azure-pipelines.yml

Lines changed: 228 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,229 @@
1-
# Python package
2-
# Create and test a Python package on multiple Python versions.
3-
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
4-
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
5-
1+
# Trigger a build when there is a push to the main branch or a tag starts with release-
62
trigger:
7-
- master
8-
9-
jobs:
10-
- job: Linux
11-
pool:
12-
vmImage: ubuntu-latest
13-
strategy:
14-
matrix:
15-
Python37:
16-
python.version: '3.7'
17-
Python38:
18-
python.version: '3.8'
19-
Python39:
20-
python.version: '3.9'
21-
22-
steps:
23-
- task: UsePythonVersion@0
24-
inputs:
25-
versionSpec: '$(python.version)'
26-
displayName: 'Use Python $(python.version)'
27-
28-
- script: |
29-
python -m pip install --upgrade pip
30-
pip install -r requirements.txt
31-
displayName: 'Install dependencies'
32-
33-
- script: |
34-
pip install cython
35-
python setup.py develop
36-
37-
- script: |
38-
pip install pytest pytest-azurepipelines
39-
pytest
40-
displayName: 'pytest'
41-
42-
- task: PublishTestResults@2
43-
inputs:
44-
testResultsFiles: 'pytest.xml'
45-
testRunTitle: '$(Agent.OS) - $(Build.BuildNumber)[$(Agent.JobName)] - Python $(python.version)'
46-
condition: succeededOrFailed()
47-
48-
- job: Windows
49-
pool:
50-
vmImage: 'windows-latest'
51-
strategy:
52-
matrix:
53-
Python37:
54-
python.version: '3.7'
55-
Python38:
56-
python.version: '3.8'
57-
Python39:
58-
python.version: '3.9'
59-
60-
steps:
61-
- task: UsePythonVersion@0
62-
inputs:
63-
versionSpec: '$(python.version)'
64-
displayName: 'Use Python $(python.version)'
65-
66-
- script: |
67-
python -m pip install --upgrade pip
68-
pip install -r requirements.txt
69-
displayName: 'Install dependencies'
70-
71-
- script: |
72-
pip install cython
73-
python setup.py develop
74-
75-
- script: |
76-
pip install pytest pytest-azurepipelines
77-
pytest
78-
displayName: 'pytest'
79-
80-
- job: MacOS
81-
pool:
82-
vmImage: 'macos-latest'
83-
strategy:
84-
matrix:
85-
Python37:
86-
python.version: '3.7'
87-
Python38:
88-
python.version: '3.8'
89-
Python39:
90-
python.version: '3.9'
91-
92-
steps:
93-
- task: UsePythonVersion@0
94-
inputs:
95-
versionSpec: '$(python.version)'
96-
displayName: 'Use Python $(python.version)'
97-
98-
- script: |
99-
python -m pip install --upgrade pip
100-
pip install -r requirements.txt
101-
displayName: 'Install dependencies'
102-
103-
- script: |
104-
pip install cython
105-
python setup.py develop
106-
107-
- script: |
108-
pip install pytest pytest-azurepipelines
109-
pytest
110-
displayName: 'pytest'
111-
112-
- job: Coverage
113-
pool:
114-
vmImage: ubuntu-latest
115-
strategy:
116-
matrix:
117-
Python39:
118-
python.version: '3.9'
119-
120-
steps:
121-
- task: UsePythonVersion@0
122-
inputs:
123-
versionSpec: '$(python.version)'
124-
displayName: 'Use Python $(python.version)'
125-
126-
- script: |
127-
python -m pip install --upgrade pip
128-
pip install -r requirements.txt
129-
displayName: 'Install dependencies'
130-
131-
- script: |
132-
pip install cython
133-
pip install pytest
134-
pip install pytest-cov
135-
pip install coveralls
136-
pip install codecov
137-
python setup.py develop
138-
139-
- script: |
140-
pip install pytest pytest-azurepipelines
141-
pytest hdbscan/tests --show-capture=no -v --disable-warnings --junitxml=pytest.xml --cov=hdbscan/ --cov-report=xml --cov-report=html
142-
codecov
143-
displayName: 'pytest'
144-
145-
- task: PublishTestResults@2
146-
inputs:
147-
testResultsFiles: 'pytest.xml'
148-
testRunTitle: '$(Agent.OS) - $(Build.BuildNumber)[$(Agent.JobName)] - Python $(python.version)'
149-
condition: succeededOrFailed()
3+
branches:
4+
include:
5+
- master
6+
tags:
7+
include:
8+
- release-*
9+
10+
# Trigger a build when there is a pull request to the main branch
11+
# Ignore PRs that are just updating the docs
12+
pr:
13+
branches:
14+
include:
15+
- master
16+
exclude:
17+
- doc/*
18+
- README.rst
19+
20+
variables:
21+
triggeredByPullRequest: $[eq(variables['Build.Reason'], 'PullRequest')]
22+
23+
stages:
24+
- stage: RunAllTests
25+
displayName: Run test suite
26+
jobs:
27+
- job: run_platform_tests
28+
strategy:
29+
matrix:
30+
mac_py37:
31+
imageName: 'macOS-latest'
32+
python.version: '3.7'
33+
linux_py37:
34+
imageName: 'ubuntu-latest'
35+
python.version: '3.7'
36+
windows_py37:
37+
imageName: 'windows-latest'
38+
python.version: '3.7'
39+
mac_py38:
40+
imageName: 'macOS-latest'
41+
python.version: '3.8'
42+
linux_py38:
43+
imageName: 'ubuntu-latest'
44+
python.version: '3.8'
45+
windows_py38:
46+
imageName: 'windows-latest'
47+
python.version: '3.8'
48+
mac_py39:
49+
imageName: 'macOS-latest'
50+
python.version: '3.9'
51+
linux_py39:
52+
imageName: 'ubuntu-latest'
53+
python.version: '3.9'
54+
windows_py39:
55+
imageName: 'windows-latest'
56+
python.version: '3.9'
57+
mac_py310:
58+
imageName: 'macOS-latest'
59+
python.version: '3.10'
60+
linux_py310:
61+
imageName: 'ubuntu-latest'
62+
python.version: '3.10'
63+
windows_py310:
64+
imageName: 'windows-latest'
65+
python.version: '3.10'
66+
67+
pool:
68+
vmImage: $(imageName)
69+
70+
steps:
71+
- task: UsePythonVersion@0
72+
inputs:
73+
versionSpec: '$(python.version)'
74+
displayName: 'Use Python $(python.version)'
75+
76+
- script: |
77+
python -m pip install --upgrade pip
78+
pip install -r requirements.txt
79+
displayName: 'Install dependencies'
80+
81+
- script: |
82+
pip install -e .
83+
pip install pytest pytest-azurepipelines
84+
pip install pytest-cov
85+
pip install coveralls
86+
displayName: 'Install package'
87+
88+
- script: |
89+
pytest hdbscan/tests --show-capture=no -v --disable-warnings --junitxml=junit/test-results.xml --cov=hdbscan/ --cov-report=xml --cov-report=html
90+
displayName: 'Run tests'
91+
92+
- bash: |
93+
coveralls
94+
displayName: 'Publish to coveralls'
95+
condition: and(succeeded(), eq(variables.triggeredByPullRequest, false)) # Don't run this for PRs because they can't access pipeline secrets
96+
env:
97+
COVERALLS_REPO_TOKEN: $(COVERALLS_TOKEN)
98+
99+
- task: PublishTestResults@2
100+
inputs:
101+
testResultsFiles: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
102+
testRunTitle: '$(Agent.OS) - $(Build.BuildNumber)[$(Agent.JobName)] - Python $(python.version)'
103+
condition: succeededOrFailed()
104+
105+
- stage: BuildPublishArtifact
106+
dependsOn: RunAllTests
107+
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/release-'), eq(variables.triggeredByPullRequest, false))
108+
jobs:
109+
# Need to use manylinux as ubuntu-latest is too new
110+
- job: Manylinux2014Build
111+
pool:
112+
vmImage: 'ubuntu-latest'
113+
container: quay.io/pypa/manylinux2014_x86_64:latest
114+
strategy:
115+
matrix:
116+
linux_py37:
117+
python.version: 'cp37-cp37m'
118+
linux_py38:
119+
python.version: 'cp38-cp38'
120+
linux_py39:
121+
python.version: 'cp39-cp39'
122+
linux_py310:
123+
python.version: 'cp310-cp310'
124+
steps:
125+
- script: |
126+
"${PYBIN}/python" -m pip install --upgrade pip
127+
"${PYBIN}/python" -m pip install wheel
128+
"${PYBIN}/python" -m pip install -r requirements.txt
129+
displayName: 'Install dependencies and build tools'
130+
env:
131+
PYBIN: /opt/python/$(python.version)/bin
132+
- script: |
133+
"${PYBIN}/python" setup.py sdist bdist_wheel
134+
displayName: 'Build wheels'
135+
env:
136+
PYBIN: /opt/python/$(python.version)/bin
137+
- bash: |
138+
auditwheel repair dist/*linux_x86_64.whl --plat manylinux2014_x86_64 -w wheelhouse-manylinux/
139+
displayName: 'Audit wheels'
140+
141+
# - task: DownloadSecureFile@1
142+
# name: PYPIRC_CONFIG
143+
# displayName: 'Download pypirc'
144+
# inputs:
145+
# secureFile: 'pypirc'
146+
147+
# - bash: |
148+
# "${PYBIN}/python" -m pip install twine
149+
# "${PYBIN}/python" -m twine upload -r testpypi --config-file $(PYPIRC_CONFIG.secureFilePath) --skip-existing --disable-progress-bar wheelhouse-manylinux/*
150+
# "${PYBIN}/python" -m twine upload -r testpypi --config-file $(PYPIRC_CONFIG.secureFilePath) --skip-existing --disable-progress-bar dist/*.tar.gz
151+
# displayName: 'Publish wheel to PyPi'
152+
# env:
153+
# PYBIN: /opt/python/$(python.version)/bin
154+
155+
- job: BuildWindowsAndMacOSArtifacts
156+
displayName: Build source dists and wheels for windows and macOS
157+
strategy:
158+
matrix:
159+
mac_py37:
160+
imageName: 'macOS-latest'
161+
python.version: '3.7'
162+
windows_py37:
163+
imageName: 'windows-latest'
164+
python.version: '3.7'
165+
mac_py38:
166+
imageName: 'macOS-latest'
167+
python.version: '3.8'
168+
windows_py38:
169+
imageName: 'windows-latest'
170+
python.version: '3.8'
171+
mac_py39:
172+
imageName: 'macOS-latest'
173+
python.version: '3.9'
174+
windows_py39:
175+
imageName: 'windows-latest'
176+
python.version: '3.9'
177+
mac_py310:
178+
imageName: 'macOS-latest'
179+
python.version: '3.10'
180+
windows_py310:
181+
imageName: 'windows-latest'
182+
python.version: '3.10'
183+
184+
pool:
185+
vmImage: $(imageName)
186+
187+
steps:
188+
- task: UsePythonVersion@0
189+
inputs:
190+
versionSpec: '$(python.version)'
191+
displayName: 'Use Python $(python.version)'
192+
193+
- script: |
194+
python -m pip install --upgrade pip
195+
pip install wheel
196+
pip install -r requirements.txt
197+
displayName: 'Install dependencies'
198+
199+
- script: |
200+
pip install -e .
201+
displayName: 'Install package locally'
202+
203+
- bash: |
204+
python setup.py sdist bdist_wheel
205+
displayName: 'Build package'
206+
207+
- bash: |
208+
export PACKAGE_VERSION="$(python setup.py --version)"
209+
echo "Package Version: ${PACKAGE_VERSION}"
210+
echo "##vso[task.setvariable variable=packageVersionFormatted;]release-${PACKAGE_VERSION}"
211+
displayName: 'Get package version'
212+
213+
- script: |
214+
echo "Version in git tag $(Build.SourceBranchName) does not match version derived from setup.py $(packageVersionFormatted)"
215+
exit 1
216+
displayName: Raise error if version doesnt match tag
217+
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], variables['packageVersionFormatted']))
218+
219+
# - task: DownloadSecureFile@1
220+
# name: PYPIRC_CONFIG
221+
# displayName: 'Download pypirc'
222+
# inputs:
223+
# secureFile: 'pypirc'
224+
225+
# - script: |
226+
# pip install twine
227+
# twine upload -r testpypi --config-file $(PYPIRC_CONFIG.secureFilePath) --skip-existing dist/*
228+
# displayName: 'Upload to PyPI'
229+
# condition: and(succeeded(), eq(variables['Build.SourceBranchName'], variables['packageVersionFormatted']))

0 commit comments

Comments
 (0)