This repository has been archived by the owner on Sep 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
win2016-azure-pipelines.yml
207 lines (185 loc) · 8.42 KB
/
win2016-azure-pipelines.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
# https://aka.ms/yaml
# https://aka.ms/hosted-agent-software
# https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/cross-platform-scripting
# https://github.com/OpenImageIO/oiio/blob/master/INSTALL.md
jobs:
- job: 'oiio'
strategy:
matrix:
windows-py36:
python.version_major: '3'
python.version_minor: '6'
python.version_patch: '4'
windows-py37:
python.version_major: '3'
python.version_minor: '7'
python.version_patch: '0'
variables:
python.version: '$(python.version_major).$(python.version_minor)'
azure.vm_image: 'vs2017-win2016'
src.python: '$(Agent.BuildDirectory)/s/src/python'
src.vcpkg: '$(Agent.BuildDirectory)/s/src/vcpkg'
tests: '$(Agent.BuildDirectory)/s/tests'
oiio.version: '2.0.5'
pypackage.os_name: 'Microsoft :: Windows'
pool:
vmImage: $(azure.vm_image)
steps:
# Select Python version to run on agent
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/use-python-version?view=azdevops
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version).$(python.version_patch)'
architecture: 'x64'
addToPath: true
# Create $(build.date) variable, to be used for GitHub release
- powershell: |
$Date = Get-Date -format "yyyyMMdd"
$DateStr = $Date.ToString()
echo "##vso[task.setvariable variable=build.date]$DateStr"
displayName: Create build.date variable
# Make setup.py ready by substituting placeholders
- powershell: |
cd $(src.python)
sed -i 's/PACKAGE_VERSION/$(oiio.version)/g' setup.py
sed -i 's/PYTHON_VERSION/$(python.version)/g' setup.py
sed -i 's/OS_NAME/$(pypackage.os_name)/g' setup.py
cat setup.py
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Inject variable values into setup.py
# Instal vcpkg
- powershell: |
cd C:/
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
.\vcpkg update
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Install vcpkg
# Copy customized port(s) into place
- powershell: |
cp -r -v $(src.vcpkg)/ports/python3-py$(python.version).$(python.version_patch)/* C:/vcpkg/ports/python3
cp -r -v $(src.vcpkg)/ports/openimageio-py$(python.version)/* C:/vcpkg/ports/openimageio
cp -r -v $(src.vcpkg)/ports/pybind11-py$(python.version)/* C:/vcpkg/ports/pybind11
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Override vcpkg port files
# Install Python Interpreter to default location
# We have to do this because pybind11 currently can't find the
# Azure-provided Python:
# Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.7")
# Fore more info, see issue #7:
# https://github.com/fredrikaverpil/oiio-python/issues/7#issuecomment-458042455
- powershell: |
choco install python --version $(python.version).$(python.version_patch)
if (Test-Path "C:/Python37/python.exe") { echo "PYTHON INTERPRETER FOUND!" }
condition: eq(variables['python.version'], '3.7')
displayName: 'Workaround: Install Python 3.7 Interpreter'
# Install pybind11 via vcpkg
- powershell: |
cd C:/vcpkg
.\vcpkg list
.\vcpkg install pybind11:x64-windows
.\vcpkg list
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Install pybind11
# Uninstall Python Interpreter
- powershell: |
if (Test-Path "C:/Python37/python.exe") { choco uninstall python -y --version $(python.version).$(python.version_patch) }
condition: eq(variables['python.version'], '3.7')
displayName: 'Workaround: Uninstall Python 3.7 Interpreter'
# Install oiio prerequisites via vcpkg
- powershell: |
cd C:/vcpkg
.\vcpkg list
.\vcpkg install openexr:x64-windows
.\vcpkg install tiff:x64-windows
.\vcpkg list
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Install oiio prerequisites
- powershell: |
$env:OIIO_PYTHON_VERSION = "$(python.version)"
cd C:/vcpkg
.\vcpkg list
.\vcpkg install openimageio:x64-windows
.\vcpkg list
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Install oiio
# Debug logs
- powershell: |
if (Test-Path "C:/vcpkg/buildtrees/openimageio/config-x64-windows-err.log") { cat C:/vcpkg/buildtrees/openimageio/config-x64-windows-err.log }
if (Test-Path "C:/vcpkg/buildtrees/openimageio/config-x64-windows-out.log") { cat C:/vcpkg/buildtrees/openimageio/config-x64-windows-out.log }
if (Test-Path "C:/vcpkg/buildtrees/openimageio/install-x64-windows-dbg-err.log") { cat C:/vcpkg/buildtrees/openimageio/install-x64-windows-dbg-err.log }
if (Test-Path "C:/vcpkg/buildtrees/openimageio/install-x64-windows-dbg-out.log") { cat C:/vcpkg/buildtrees/openimageio/install-x64-windows-dbg-out.log }
if (Test-Path "C:/vcpkg/buildtrees/openimageio/install-x64-windows-rel-err.log") { cat C:/vcpkg/buildtrees/openimageio/install-x64-windows-rel-err.log }
if (Test-Path "C:/vcpkg/buildtrees/openimageio/install-x64-windows-rel-out.log") { cat C:/vcpkg/buildtrees/openimageio/install-x64-windows-rel-out.log }
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Build logs for oiio
# View files from built and installed oiio
- powershell: |
cd C:\vcpkg\installed\x64-windows\bin
tree /F
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Show contents of oiio bin folder tree
- powershell: |
cd C:\vcpkg\installed\x64-windows\lib\python$(python.version)\site-packages
tree /F
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Show contents of oiio site-packages folder tree
# Copy files into Python package
- powershell: |
cp -r -v C:\vcpkg\installed\x64-windows\lib\python$(python.version)\site-packages\*.pyd $(src.python)/oiio
cp -r -v C:\vcpkg\installed\x64-windows\bin\*.dll $(src.python)/oiio
cd $(src.python)
tree /F
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Copy files into oiio Python package
- powershell: |
cd $(src.python)
python -m pip install -U pip
pip install -U setuptools wheel
python setup.py bdist_wheel --python-tag=cp$(python.version_major)$(python.version_minor) --plat-name=win-amd64 --dist-dir="$(Build.ArtifactStagingDirectory)"
cd $(Build.ArtifactStagingDirectory)
tree /F
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Build wheel
# Publish wheel as build artifact (see "Summary" in Azure Pipelines build)
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/publish-build-artifacts?view=azdevops
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: drop-$(python.version)
# Tests
- powershell: |
cd $(tests)
python --version
pip list
dir
python -m pip install --find-links=$(Build.ArtifactStagingDirectory) oiio
pip install pytest
pip list
pytest --verbose
displayName: Run rudimental test(s)
# GitHub Release
# Create, edit, or discard a GitHub release.
# https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks/GitHubReleaseV0
# https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/github-release?view=azdevops
- task: GithubRelease@0
inputs:
gitHubConnection: 'oiio-python-releases'
repositoryName: 'fredrikaverpil/oiio-python'
action: 'edit' # Options: create, edit, discard
target: '$(build.sourceVersion)' # Required when action == create || action == edit
tagSource: 'Git tag' # Required when action == create. Options: auto, manual
tag: '$(oiio.version)+$(build.date)' # Required when action == edit || action == discard || tagSource == manual
title: '$(oiio.version)+$(build.date)'
#releaseNotesSource: 'file' # Optional. Options: file, input
#releaseNotesFile: # Optional
#releaseNotes: # Optional
# assets: '$(build.artifactStagingDirectory)/*' # Optional
# assets: '$(Build.ArtifactStagingDirectory)' # Optional
assetUploadMode: 'replace' # Optional. Options: delete, replace
#isDraft: false # Optional
#isPreRelease: false # Optional
addChangeLog: false # Optional
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')