Skip to content

Commit b440277

Browse files
eserscorCopilot
andauthored
win arm64 python packages (#27299)
### Description Adds arm64 windows python packages to the build ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5a9d721 commit b440277

File tree

3 files changed

+180
-126
lines changed

3 files changed

+180
-126
lines changed

tools/ci_build/github/azure-pipelines/nuget/templates/dml-vs-2022.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ stages:
4949
clean: true
5050
submodules: none
5151

52-
53-
- template: ../../templates/setup-build-tools.yml
52+
53+
- template: ../../templates/setup-build-tools.yml
5454
parameters:
5555
host_cpu_arch: 'x64'
5656

tools/ci_build/github/azure-pipelines/stages/py-cpu-packaging-stage.yml

Lines changed: 10 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -66,131 +66,17 @@ stages:
6666
- stage: Python_Packaging_Windows_CPU
6767
dependsOn: []
6868
jobs:
69-
- job: Windows_py_Wheels
70-
pool:
71-
name: 'onnxruntime-Win-CPU-VS2022-Latest'
72-
os: windows
73-
templateContext:
74-
sdl:
75-
codeSignValidation:
76-
enabled: true
77-
# TODO: check why pyd file was not signed
78-
break: false
79-
additionalTargetsGlobPattern: f|**\*.pyd
80-
psscriptanalyzer:
81-
enabled: true
82-
binskim:
83-
enabled: true
84-
scanOutputDirectoryOnly: true
85-
outputs:
86-
- output: pipelineArtifact
87-
targetPath: $(Build.ArtifactStagingDirectory)
88-
artifactName: onnxruntime-win-$(PythonVersion)
89-
strategy:
90-
matrix:
91-
Python311_x64:
92-
PythonVersion: '3.11'
93-
Python312_x64:
94-
PythonVersion: '3.12'
95-
Python313_x64:
96-
PythonVersion: '3.13'
97-
Python314_x64:
98-
PythonVersion: '3.14'
99-
variables:
100-
OnnxRuntimeBuildDirectory: '$(Build.BinariesDirectory)'
101-
ExtraParam: ${{ parameters.build_py_parameters }}
102-
timeoutInMinutes: 180
103-
workspace:
104-
clean: all
105-
106-
steps:
107-
- checkout: self
108-
clean: true
109-
submodules: recursive
110-
111-
- template: ../templates/setup-build-tools.yml
112-
parameters:
113-
host_cpu_arch: 'x64'
114-
python_version: $(PythonVersion)
115-
116-
- template: ../templates/set-nightly-build-option-variable-step.yml
117-
118-
- script: python -m pip install -r $(Build.SourcesDirectory)\tools\ci_build\github\windows\python\requirements.txt
119-
env:
120-
TMPDIR: "$(Agent.TempDirectory)"
121-
122-
- task: PythonScript@0
123-
displayName: 'Build'
124-
inputs:
125-
scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py'
126-
arguments: >
127-
--config ${{ parameters.cmake_build_type }}
128-
--enable_lto
129-
--build_dir $(Build.SourcesDirectory)\build
130-
--skip_submodule_sync
131-
--cmake_generator "Visual Studio 17 2022"
132-
--enable_pybind
133-
--enable_onnx_tests --use_vcpkg --use_vcpkg_ms_internal_asset_cache
134-
${{ parameters.build_py_parameters }}
135-
--parallel --use_binskim_compliant_compile_flags --update --build
136-
$(TelemetryOption)
137-
138-
- ${{if or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/rel-'))}}:
139-
- template: ../templates/publish-symbolrequestprod-api.yml
140-
parameters:
141-
${{if eq(variables['Build.SourceBranch'], 'refs/heads/main')}}:
142-
symbolExpiryTime: 60
143-
includePublicSymbolServer: true
144-
symbolsArtifactName: onnxruntime_cpu_win_x64_$(PythonVersion)
145-
symbolsVersion: $(Build.BuildId)
146-
symbolProject: 'ONNX Runtime'
147-
subscription: 'OnnxrunTimeCodeSign_20240611'
148-
searchPattern: |
149-
$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\onnxruntime.pdb
150-
$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\onnxruntime_providers_shared.pdb
151-
$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\onnxruntime_pybind11_state.pdb
152-
153-
# Esrp signing
154-
- template: ../templates/win-esrp-dll.yml
155-
parameters:
156-
FolderPath: '$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\onnxruntime\capi'
157-
DisplayName: 'ESRP - Sign Native dlls'
158-
DoEsrp: true
159-
Pattern: '*.pyd,*.dll'
160-
161-
- task: PythonScript@0
162-
displayName: 'Build wheel'
163-
inputs:
164-
scriptPath: '$(Build.SourcesDirectory)\setup.py'
165-
arguments: 'bdist_wheel ${{ parameters.build_py_parameters }} $(NightlyBuildOption)'
166-
workingDirectory: '$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}'
167-
168-
- task: CopyFiles@2
169-
displayName: 'Copy Python Wheel to: $(Build.ArtifactStagingDirectory)'
170-
inputs:
171-
SourceFolder: '$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}\dist'
172-
Contents: '*.whl'
173-
TargetFolder: '$(Build.ArtifactStagingDirectory)'
174-
175-
- script: |
176-
7z x *.whl
177-
workingDirectory: '$(Build.ArtifactStagingDirectory)'
178-
displayName: 'unzip the package'
179-
69+
- template: ../templates/py-win-cpu.yml
70+
parameters:
71+
architecture: 'x64'
72+
build_py_parameters: ${{ parameters.build_py_parameters }}
73+
cmake_build_type: ${{ parameters.cmake_build_type }}
18074

181-
- powershell: |
182-
if ("$(PythonVersion)" -notcontains "3.14") {
183-
python -m pip uninstall -y onnxruntime onnxruntime-gpu -qq
184-
Get-ChildItem -Path $(Build.ArtifactStagingDirectory)/*.whl | foreach {pip --disable-pip-version-check install --upgrade $_.fullname tabulate}
185-
Remove-Item -Recurse -Force onnxruntime
186-
if ("$(ExtraParam)" -contains "--use_azure") {
187-
$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"
188-
python onnxruntime_test_python_azure.py
189-
}
190-
python onnx_backend_test_series.py
191-
}
192-
workingDirectory: '$(Build.SourcesDirectory)\build\${{ parameters.cmake_build_type }}\${{ parameters.cmake_build_type }}'
193-
displayName: 'Run Python Tests'
75+
- template: ../templates/py-win-cpu.yml
76+
parameters:
77+
architecture: 'arm64'
78+
build_py_parameters: ${{ parameters.build_py_parameters }}
79+
cmake_build_type: ${{ parameters.cmake_build_type }}
19480

19581
- ${{ if eq(parameters.enable_mac_cpu, true) }}:
19682
- stage: Python_Packaging_MacOS
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
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

Comments
 (0)