Skip to content

Commit 61c16f2

Browse files
authored
Merge pull request #606 from gclendenning/master
Build platform dependent wheel files
2 parents e5e1b8e + df1b1dc commit 61c16f2

File tree

1 file changed

+243
-148
lines changed

1 file changed

+243
-148
lines changed

azure-pipelines.yml

Lines changed: 243 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,244 @@
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+
mac_py311:
67+
imageName: 'macOS-latest'
68+
python.version: '3.11'
69+
linux_py311:
70+
imageName: 'ubuntu-latest'
71+
python.version: '3.11'
72+
windows_py311:
73+
imageName: 'windows-latest'
74+
python.version: '3.11'
75+
pool:
76+
vmImage: $(imageName)
77+
78+
steps:
79+
- task: UsePythonVersion@0
80+
inputs:
81+
versionSpec: '$(python.version)'
82+
displayName: 'Use Python $(python.version)'
83+
84+
- script: |
85+
python -m pip install --upgrade pip
86+
pip install -r requirements.txt
87+
displayName: 'Install dependencies'
88+
89+
- script: |
90+
pip install -e .
91+
pip install pytest pytest-azurepipelines
92+
pip install pytest-cov
93+
pip install coveralls
94+
displayName: 'Install package'
95+
96+
- script: |
97+
pytest hdbscan/tests --show-capture=no -v --disable-warnings --junitxml=junit/test-results.xml --cov=hdbscan/ --cov-report=xml --cov-report=html
98+
displayName: 'Run tests'
99+
100+
- bash: |
101+
coveralls
102+
displayName: 'Publish to coveralls'
103+
condition: and(succeeded(), eq(variables.triggeredByPullRequest, false)) # Don't run this for PRs because they can't access pipeline secrets
104+
env:
105+
COVERALLS_REPO_TOKEN: $(COVERALLS_TOKEN)
106+
107+
- task: PublishTestResults@2
108+
inputs:
109+
testResultsFiles: '$(System.DefaultWorkingDirectory)/**/coverage.xml'
110+
testRunTitle: '$(Agent.OS) - $(Build.BuildNumber)[$(Agent.JobName)] - Python $(python.version)'
111+
condition: succeededOrFailed()
112+
113+
- stage: BuildPublishArtifact
114+
dependsOn: RunAllTests
115+
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/release-'), eq(variables.triggeredByPullRequest, false))
116+
jobs:
117+
# Need to use manylinux as ubuntu-latest is too new
118+
- job: Manylinux2014Build
119+
pool:
120+
vmImage: 'ubuntu-latest'
121+
container: quay.io/pypa/manylinux2014_x86_64:latest
122+
strategy:
123+
matrix:
124+
linux_py37:
125+
python.version: 'cp37-cp37m'
126+
linux_py38:
127+
python.version: 'cp38-cp38'
128+
linux_py39:
129+
python.version: 'cp39-cp39'
130+
linux_py310:
131+
python.version: 'cp310-cp310'
132+
linux_py311:
133+
python.version: 'cp311-cp311'
134+
steps:
135+
- script: |
136+
"${PYBIN}/python" -m pip install --upgrade pip
137+
"${PYBIN}/python" -m pip install wheel
138+
"${PYBIN}/python" -m pip install -r requirements.txt
139+
displayName: 'Install dependencies and build tools'
140+
env:
141+
PYBIN: /opt/python/$(python.version)/bin
142+
- script: |
143+
"${PYBIN}/python" setup.py sdist bdist_wheel
144+
displayName: 'Build wheels'
145+
env:
146+
PYBIN: /opt/python/$(python.version)/bin
147+
- bash: |
148+
auditwheel repair dist/*linux_x86_64.whl --plat manylinux2014_x86_64 -w wheelhouse-manylinux/
149+
displayName: 'Audit wheels'
150+
151+
- task: DownloadSecureFile@1
152+
name: PYPIRC_CONFIG
153+
displayName: 'Download pypirc'
154+
inputs:
155+
secureFile: 'pypirc'
156+
157+
- bash: |
158+
"${PYBIN}/python" -m pip install twine
159+
"${PYBIN}/python" -m twine upload -r pypi --config-file $(PYPIRC_CONFIG.secureFilePath) --skip-existing --disable-progress-bar wheelhouse-manylinux/*
160+
"${PYBIN}/python" -m twine upload -r pypi --config-file $(PYPIRC_CONFIG.secureFilePath) --skip-existing --disable-progress-bar dist/*.tar.gz
161+
displayName: 'Publish wheel to PyPi'
162+
env:
163+
PYBIN: /opt/python/$(python.version)/bin
164+
165+
- job: BuildWindowsAndMacOSArtifacts
166+
displayName: Build source dists and wheels for windows and macOS
167+
strategy:
168+
matrix:
169+
mac_py37:
170+
imageName: 'macOS-latest'
171+
python.version: '3.7'
172+
windows_py37:
173+
imageName: 'windows-latest'
174+
python.version: '3.7'
175+
mac_py38:
176+
imageName: 'macOS-latest'
177+
python.version: '3.8'
178+
windows_py38:
179+
imageName: 'windows-latest'
180+
python.version: '3.8'
181+
mac_py39:
182+
imageName: 'macOS-latest'
183+
python.version: '3.9'
184+
windows_py39:
185+
imageName: 'windows-latest'
186+
python.version: '3.9'
187+
mac_py310:
188+
imageName: 'macOS-latest'
189+
python.version: '3.10'
190+
windows_py310:
191+
imageName: 'windows-latest'
192+
python.version: '3.10'
193+
mac_py311:
194+
imageName: 'macOS-latest'
195+
python.version: '3.11'
196+
windows_py311:
197+
imageName: 'windows-latest'
198+
python.version: '3.11'
199+
pool:
200+
vmImage: $(imageName)
201+
202+
steps:
203+
- task: UsePythonVersion@0
204+
inputs:
205+
versionSpec: '$(python.version)'
206+
displayName: 'Use Python $(python.version)'
207+
208+
- script: |
209+
python -m pip install --upgrade pip
210+
pip install wheel
211+
pip install -r requirements.txt
212+
displayName: 'Install dependencies'
213+
214+
- script: |
215+
pip install -e .
216+
displayName: 'Install package locally'
217+
218+
- bash: |
219+
python setup.py sdist bdist_wheel
220+
displayName: 'Build package'
221+
222+
- bash: |
223+
export PACKAGE_VERSION="$(python setup.py --version)"
224+
echo "Package Version: ${PACKAGE_VERSION}"
225+
echo "##vso[task.setvariable variable=packageVersionFormatted;]release-${PACKAGE_VERSION}"
226+
displayName: 'Get package version'
227+
228+
- script: |
229+
echo "Version in git tag $(Build.SourceBranchName) does not match version derived from setup.py $(packageVersionFormatted)"
230+
exit 1
231+
displayName: Raise error if version doesnt match tag
232+
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], variables['packageVersionFormatted']))
233+
234+
- task: DownloadSecureFile@1
235+
name: PYPIRC_CONFIG
236+
displayName: 'Download pypirc'
237+
inputs:
238+
secureFile: 'pypirc'
239+
240+
- script: |
241+
pip install twine
242+
twine upload -r pypi --config-file $(PYPIRC_CONFIG.secureFilePath) --skip-existing dist/*
243+
displayName: 'Upload to PyPI'
244+
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], variables['packageVersionFormatted']))

0 commit comments

Comments
 (0)