|
| 1 | +parameters: |
| 2 | +- name: architecture |
| 3 | + type: string |
| 4 | + default: 'x64' |
| 5 | + values: |
| 6 | + - x64 |
| 7 | + - arm64 |
| 8 | + |
| 9 | +- name: build_py_parameters |
| 10 | + displayName: 'Specify extra build parameters' |
| 11 | + type: string |
| 12 | + default: '--use_azure' |
| 13 | + |
| 14 | +- name: cmake_build_type |
| 15 | + type: string |
| 16 | + displayName: 'CMake build type for Windows. Only for Windows CPU packages.' |
| 17 | + default: 'RelWithDebInfo' |
| 18 | + values: |
| 19 | + - Debug |
| 20 | + - Release |
| 21 | + - RelWithDebInfo |
| 22 | + - MinSizeRel |
| 23 | + |
| 24 | +jobs: |
| 25 | +- job: Windows_py_Wheels_${{parameters.architecture}} |
| 26 | + ${{ if eq(parameters.architecture, 'arm64') }}: |
| 27 | + pool: |
| 28 | + name: 'onnxruntime-qnn-windows-vs-2022-arm64' |
| 29 | + os: windows |
| 30 | + hostArchitecture: Arm64 |
| 31 | + demands: |
| 32 | + - Agent.Version -equals 4.264.2 |
| 33 | + ${{ else }}: |
| 34 | + pool: |
| 35 | + name: 'onnxruntime-Win-CPU-VS2022-Latest' |
| 36 | + os: windows |
| 37 | + templateContext: |
| 38 | + sdl: |
| 39 | + codeSignValidation: |
| 40 | + enabled: true |
| 41 | + # TODO: check why pyd file was not signed |
| 42 | + break: false |
| 43 | + additionalTargetsGlobPattern: f|**\*.pyd |
| 44 | + psscriptanalyzer: |
| 45 | + enabled: true |
| 46 | + binskim: |
| 47 | + enabled: true |
| 48 | + scanOutputDirectoryOnly: true |
| 49 | + ${{ if eq(parameters.architecture, 'arm64') }}: |
| 50 | + outputs: |
| 51 | + - output: pipelineArtifact |
| 52 | + targetPath: $(Build.ArtifactStagingDirectory) |
| 53 | + artifactName: onnxruntime-win-$(PythonVersion)-arm64 |
| 54 | + ${{ else }}: |
| 55 | + outputs: |
| 56 | + - output: pipelineArtifact |
| 57 | + targetPath: $(Build.ArtifactStagingDirectory) |
| 58 | + artifactName: onnxruntime-win-$(PythonVersion) |
| 59 | + strategy: |
| 60 | + matrix: |
| 61 | + Python311_${{parameters.architecture}}: |
| 62 | + PythonVersion: '3.11' |
| 63 | + Python312_${{parameters.architecture}}: |
| 64 | + PythonVersion: '3.12' |
| 65 | + Python313_${{parameters.architecture}}: |
| 66 | + PythonVersion: '3.13' |
| 67 | + Python314_${{parameters.architecture}}: |
| 68 | + PythonVersion: '3.14' |
| 69 | + variables: |
| 70 | + OnnxRuntimeBuildDirectory: '$(Build.BinariesDirectory)' |
| 71 | + ExtraParam: ${{ parameters.build_py_parameters }} |
| 72 | + timeoutInMinutes: 180 |
| 73 | + workspace: |
| 74 | + clean: all |
| 75 | + |
| 76 | + steps: |
| 77 | + - checkout: self |
| 78 | + clean: true |
| 79 | + submodules: recursive |
| 80 | + |
| 81 | + - template: setup-build-tools.yml |
| 82 | + parameters: |
| 83 | + host_cpu_arch: ${{parameters.architecture}} |
| 84 | + python_version: $(PythonVersion) |
| 85 | + |
| 86 | + - template: set-nightly-build-option-variable-step.yml |
| 87 | + |
| 88 | + - script: python -m pip install -r $(Build.SourcesDirectory)\tools\ci_build\github\windows\python\requirements.txt |
| 89 | + env: |
| 90 | + TMPDIR: "$(Agent.TempDirectory)" |
| 91 | + |
| 92 | + - task: PythonScript@0 |
| 93 | + displayName: 'Build' |
| 94 | + inputs: |
| 95 | + scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py' |
| 96 | + arguments: > |
| 97 | + --config ${{ parameters.cmake_build_type }} |
| 98 | + --enable_lto |
| 99 | + --build_dir $(Build.SourcesDirectory)\build |
| 100 | + --skip_submodule_sync |
| 101 | + --cmake_generator "Visual Studio 17 2022" |
| 102 | + --enable_pybind |
| 103 | + --enable_onnx_tests --use_vcpkg --use_vcpkg_ms_internal_asset_cache --build |
| 104 | + ${{ parameters.build_py_parameters }} |
| 105 | + --parallel --use_binskim_compliant_compile_flags --update |
| 106 | + $(TelemetryOption) |
| 107 | +
|
| 108 | + - ${{if or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/rel-'))}}: |
| 109 | + - template: publish-symbolrequestprod-api.yml |
| 110 | + parameters: |
| 111 | + ${{if eq(variables['Build.SourceBranch'], 'refs/heads/main')}}: |
| 112 | + symbolExpiryTime: 60 |
| 113 | + includePublicSymbolServer: true |
| 114 | + symbolsArtifactName: onnxruntime_cpu_win_${{ parameters.architecture }}_$(PythonVersion) |
| 115 | + symbolsVersion: $(Build.BuildId) |
| 116 | + symbolProject: 'ONNX Runtime' |
| 117 | + subscription: 'OnnxrunTimeCodeSign_20240611' |
| 118 | + searchPattern: | |
| 119 | + $(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\onnxruntime.pdb |
| 120 | + $(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\onnxruntime_providers_shared.pdb |
| 121 | + $(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\onnxruntime_pybind11_state.pdb |
| 122 | +
|
| 123 | + # Esrp signing |
| 124 | + - template: win-esrp-dll.yml |
| 125 | + parameters: |
| 126 | + FolderPath: '$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\onnxruntime\capi' |
| 127 | + DisplayName: 'ESRP - Sign Native dlls' |
| 128 | + DoEsrp: true |
| 129 | + Pattern: '*.pyd,*.dll' |
| 130 | + |
| 131 | + - task: PythonScript@0 |
| 132 | + displayName: 'Build wheel' |
| 133 | + inputs: |
| 134 | + scriptPath: '$(Build.SourcesDirectory)\setup.py' |
| 135 | + arguments: 'bdist_wheel ${{ parameters.build_py_parameters }} $(NightlyBuildOption)' |
| 136 | + workingDirectory: '$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}' |
| 137 | + |
| 138 | + - task: CopyFiles@2 |
| 139 | + displayName: 'Copy Python Wheel to: $(Build.ArtifactStagingDirectory)' |
| 140 | + inputs: |
| 141 | + SourceFolder: '$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\dist' |
| 142 | + Contents: '*.whl' |
| 143 | + TargetFolder: '$(Build.ArtifactStagingDirectory)' |
| 144 | + |
| 145 | + - script: | |
| 146 | + 7z x *.whl |
| 147 | + workingDirectory: '$(Build.ArtifactStagingDirectory)' |
| 148 | + displayName: 'unzip the package' |
| 149 | +
|
| 150 | +
|
| 151 | + - powershell: | |
| 152 | + if ("$(PythonVersion)" -notcontains "3.14") { |
| 153 | + python -m pip uninstall -y onnxruntime onnxruntime-gpu -qq |
| 154 | + Get-ChildItem -Path $(Build.ArtifactStagingDirectory)/*.whl | foreach {pip --disable-pip-version-check install --upgrade $_.fullname tabulate} |
| 155 | + Remove-Item -Recurse -Force onnxruntime |
| 156 | + if ("$(ExtraParam)".Split() -contains "--use_azure") { |
| 157 | +
|
| 158 | + if( "${{parameters.architecture}}" -eq 'arm64') { |
| 159 | + $env:path="$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\_deps\vcpkg-src\installed\arm64-windows\bin;$env:path" |
| 160 | + } else { |
| 161 | + $env:path="$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\_deps\vcpkg-src\installed\x64-windows\bin;$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\_deps\vcpkg-src\installed\x86-windows\bin;$env:path" |
| 162 | + } |
| 163 | + python onnxruntime_test_python_azure.py |
| 164 | + } |
| 165 | + python onnx_backend_test_series.py |
| 166 | + } |
| 167 | + workingDirectory: '$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}' |
| 168 | + displayName: 'Run Python Tests' |
0 commit comments