Skip to content

Commit e7720fa

Browse files
committed
bpo-33125: Add support for building and releasing Windows ARM64 packages
1 parent 4d231bc commit e7720fa

27 files changed

+272
-74
lines changed

.azure-pipelines/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145
buildOpt: '-p x64'
146146
testRunTitle: '$(Build.SourceBranchName)-win64'
147147
testRunPlatform: win64
148-
maxParallel: 2
148+
maxParallel: 4
149149

150150
steps:
151151
- template: ./windows-steps.yml

.azure-pipelines/pr.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ jobs:
145145
buildOpt: '-p x64'
146146
testRunTitle: '$(System.PullRequest.TargetBranch)-win64'
147147
testRunPlatform: win64
148-
maxParallel: 2
148+
winarm64:
149+
arch: arm64
150+
buildOpt: '-p arm64'
151+
maxParallel: 4
149152

150153
steps:
151154
- template: ./windows-steps.yml

.azure-pipelines/windows-release/build-steps.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ steps:
4343

4444
- powershell: |
4545
$env:SigningCertificate = $null
46-
.\python.bat PC\layout -vv -t "$(Build.BinariesDirectory)\catalog" --catalog "${env:CAT}.cdf" --preset-default
46+
python PC\layout -vv -b "$(Build.BinariesDirectory)\bin" -t "$(Build.BinariesDirectory)\catalog" --catalog "${env:CAT}.cdf" --preset-default --arch $(Arch)
4747
makecat "${env:CAT}.cdf"
4848
del "${env:CAT}.cdf"
4949
if (-not (Test-Path "${env:CAT}.cat")) {
@@ -52,6 +52,7 @@ steps:
5252
displayName: 'Generate catalog'
5353
env:
5454
CAT: $(Build.BinariesDirectory)\bin\$(Arch)\python
55+
PYTHON_HEXVERSION: $(VersionHex)
5556

5657
- task: PublishPipelineArtifact@0
5758
displayName: 'Publish binaries'

.azure-pipelines/windows-release/layout-command.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
steps:
2+
- task: DownloadPipelineArtifact@1
3+
displayName: 'Download artifact: bin_$(HostArch)'
4+
condition: and(succeeded(), variables['HostArch'])
5+
inputs:
6+
artifactName: bin_$(HostArch)
7+
targetPath: $(Build.BinariesDirectory)\bin_$(HostArch)
8+
29
- powershell: >
310
Write-Host (
411
'##vso[task.setvariable variable=LayoutCmd]&
5-
"{0}\bin\python.exe"
12+
"$(Python)"
613
"{1}\PC\layout"
714
-vv
815
--source "{1}"
916
--build "{0}\bin"
17+
--arch "$(Name)"
1018
--temp "{0}\layout-temp"
1119
--include-cat "{0}\bin\python.cat"
1220
--doc-build "{0}\doc"'

.azure-pipelines/windows-release/msi-steps.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ steps:
5454
- powershell: |
5555
copy $(Build.BinariesDirectory)\amd64\Activate.ps1 Lib\venv\scripts\common\Activate.ps1 -Force
5656
displayName: 'Copy signed files into sources'
57+
condition: and(succeeded(), variables['SigningCertificate'])
5758
5859
- script: |
5960
call Tools\msi\get_externals.bat

.azure-pipelines/windows-release/stage-build.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ jobs:
1616
env:
1717
BUILDDIR: $(Build.BinariesDirectory)\Doc
1818

19-
#- powershell: iwr "https://www.python.org/ftp/python/3.7.3/python373.chm" -OutFile "$(Build.BinariesDirectory)\python390a0.chm"
20-
# displayName: 'Cheat at building CHM docs'
21-
2219
- script: Doc\make.bat htmlhelp
2320
displayName: 'Build CHM docs'
2421
env:
2522
BUILDDIR: $(Build.BinariesDirectory)\Doc
2623

24+
#- powershell: |
25+
# mkdir -Force "$(Build.BinariesDirectory)\Doc\htmlhelp"
26+
# iwr "https://www.python.org/ftp/python/3.8.0/python380.chm" -OutFile "$(Build.BinariesDirectory)\Doc\htmlhelp\python390a0.chm"
27+
# displayName: 'Cheat at building CHM docs'
28+
2729
- task: CopyFiles@2
2830
displayName: 'Assemble artifact: Doc'
2931
inputs:
@@ -65,6 +67,16 @@ jobs:
6567
Arch: amd64
6668
Platform: x64
6769
Configuration: Debug
70+
arm64:
71+
Name: arm64
72+
Arch: arm64
73+
Platform: ARM64
74+
Configuration: Release
75+
arm64_d:
76+
Name: arm64_d
77+
Arch: arm64
78+
Platform: ARM64
79+
Configuration: Debug
6880

6981
steps:
7082
- template: ./build-steps.yml

.azure-pipelines/windows-release/stage-layout-embed.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ jobs:
1919
Name: amd64
2020
Python: $(Build.BinariesDirectory)\bin\python.exe
2121
PYTHONHOME: $(Build.SourcesDirectory)
22+
arm64:
23+
Name: arm64
24+
HostArch: amd64
25+
Python: $(Build.BinariesDirectory)\bin_amd64\python.exe
26+
PYTHONHOME: $(Build.SourcesDirectory)
2227

2328
steps:
2429
- template: ./checkout.yml

.azure-pipelines/windows-release/stage-layout-full.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ jobs:
1313
matrix:
1414
win32:
1515
Name: win32
16-
Python: $(Build.BinariesDirectory)\bin_$(Name)\python.exe
16+
Python: $(Build.BinariesDirectory)\bin\python.exe
1717
PYTHONHOME: $(Build.SourcesDirectory)
18+
TclLibrary: $(Build.BinariesDirectory)\tcltk_lib\tcl8
1819
amd64:
1920
Name: amd64
20-
Python: $(Build.BinariesDirectory)\bin_$(Name)\python.exe
21+
Python: $(Build.BinariesDirectory)\bin\python.exe
22+
PYTHONHOME: $(Build.SourcesDirectory)
23+
TclLibrary: $(Build.BinariesDirectory)\tcltk_lib\tcl8
24+
arm64:
25+
Name: arm64
26+
HostArch: amd64
27+
Python: $(Build.BinariesDirectory)\bin_amd64\python.exe
2128
PYTHONHOME: $(Build.SourcesDirectory)
2229

2330
steps:
@@ -43,21 +50,23 @@ jobs:
4350

4451
- task: DownloadPipelineArtifact@1
4552
displayName: 'Download artifact: tcltk_lib_$(Name)'
53+
condition: and(succeeded(), variables['TclLibrary'])
4654
inputs:
4755
artifactName: tcltk_lib_$(Name)
4856
targetPath: $(Build.BinariesDirectory)\tcltk_lib
4957

5058
- powershell: |
51-
copy $(Build.BinariesDirectory)\bin\Activate.ps1 Lib\venv\scripts\common\Activate.ps1 -Force
59+
copy "$(Build.BinariesDirectory)\bin\Activate.ps1" Lib\venv\scripts\common\Activate.ps1 -Force
5260
displayName: 'Copy signed files into sources'
61+
condition: and(succeeded(), variables['SigningCertificate'])
5362
5463
- template: ./layout-command.yml
5564

5665
- powershell: |
5766
$(LayoutCmd) --copy "$(Build.ArtifactStagingDirectory)\layout" --preset-default
5867
displayName: 'Generate full layout'
5968
env:
60-
TCL_LIBRARY: $(Build.BinariesDirectory)\tcltk_lib\tcl8
69+
TCL_LIBRARY: $(TclLibrary)
6170
6271
- task: PublishPipelineArtifact@0
6372
displayName: 'Publish Artifact: layout_full_$(Name)'

.azure-pipelines/windows-release/stage-layout-msix.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ jobs:
1212
matrix:
1313
#win32:
1414
# Name: win32
15-
# Python: $(Build.BinariesDirectory)\bin_$(Name)\python.exe
15+
# Python: $(Build.BinariesDirectory)\bin\python.exe
1616
# PYTHONHOME: $(Build.SourcesDirectory)
17+
# TclLibrary: $(Build.BinariesDirectory)\tcltk_lib\tcl8
1718
amd64:
1819
Name: amd64
19-
Python: $(Build.BinariesDirectory)\bin_$(Name)\python.exe
20+
Python: $(Build.BinariesDirectory)\bin\python.exe
21+
PYTHONHOME: $(Build.SourcesDirectory)
22+
TclLibrary: $(Build.BinariesDirectory)\tcltk_lib\tcl8
23+
arm64:
24+
Name: arm64
25+
HostArch: amd64
26+
Python: $(Build.BinariesDirectory)\bin_amd64\python.exe
2027
PYTHONHOME: $(Build.SourcesDirectory)
2128

2229
steps:
@@ -36,13 +43,15 @@ jobs:
3643

3744
- task: DownloadPipelineArtifact@1
3845
displayName: 'Download artifact: tcltk_lib_$(Name)'
46+
condition: and(succeeded(), variables['TclLibrary'])
3947
inputs:
4048
artifactName: tcltk_lib_$(Name)
4149
targetPath: $(Build.BinariesDirectory)\tcltk_lib
4250

4351
- powershell: |
44-
copy $(Build.BinariesDirectory)\bin\Activate.ps1 Lib\venv\scripts\common\Activate.ps1 -Force
52+
copy "$(Build.BinariesDirectory)\bin\Activate.ps1" Lib\venv\scripts\common\Activate.ps1 -Force
4553
displayName: 'Copy signed files into sources'
54+
condition: and(succeeded(), variables['SigningCertificate'])
4655
4756
- template: ./layout-command.yml
4857

@@ -51,7 +60,7 @@ jobs:
5160
$(LayoutCmd) --copy "$(Build.ArtifactStagingDirectory)\appx-store" --preset-appx --precompile
5261
displayName: 'Generate store APPX layout'
5362
env:
54-
TCL_LIBRARY: $(Build.BinariesDirectory)\tcltk_lib\tcl8
63+
TCL_LIBRARY: $(TclLibrary)
5564
5665
- task: PublishPipelineArtifact@0
5766
displayName: 'Publish Artifact: layout_appxstore_$(Name)'
@@ -79,7 +88,7 @@ jobs:
7988
$(LayoutCmd) --copy "$(Build.ArtifactStagingDirectory)\appx" --preset-appx --precompile --include-symbols --include-tests
8089
displayName: 'Generate sideloading APPX layout'
8190
env:
82-
TCL_LIBRARY: $(Build.BinariesDirectory)\tcltk_lib\tcl8
91+
TCL_LIBRARY: $(TclLibrary)
8392
8493
- task: PublishPipelineArtifact@0
8594
displayName: 'Publish Artifact: layout_appx_$(Name)'

.azure-pipelines/windows-release/stage-layout-nuget.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ jobs:
1313
matrix:
1414
win32:
1515
Name: win32
16-
Python: $(Build.BinariesDirectory)\bin_$(Name)\python.exe
16+
Python: $(Build.BinariesDirectory)\bin\python.exe
1717
PYTHONHOME: $(Build.SourcesDirectory)
1818
amd64:
1919
Name: amd64
20-
Python: $(Build.BinariesDirectory)\bin_$(Name)\python.exe
20+
Python: $(Build.BinariesDirectory)\bin\python.exe
21+
PYTHONHOME: $(Build.SourcesDirectory)
22+
arm64:
23+
Name: arm64
24+
HostArch: amd64
25+
Python: $(Build.BinariesDirectory)\bin_amd64\python.exe
2126
PYTHONHOME: $(Build.SourcesDirectory)
2227

2328
steps:
@@ -32,14 +37,13 @@ jobs:
3237
- powershell: |
3338
copy $(Build.BinariesDirectory)\bin\Activate.ps1 Lib\venv\scripts\common\Activate.ps1 -Force
3439
displayName: 'Copy signed files into sources'
40+
condition: and(succeeded(), variables['SigningCertificate'])
3541
3642
- template: ./layout-command.yml
3743

3844
- powershell: |
3945
$(LayoutCmd) --copy "$(Build.ArtifactStagingDirectory)\nuget" --preset-nuget
4046
displayName: 'Generate nuget layout'
41-
env:
42-
TCL_LIBRARY: $(Build.BinariesDirectory)\bin_$(Name)\tcl\tcl8
4347
4448
- task: PublishPipelineArtifact@0
4549
displayName: 'Publish Artifact: layout_nuget_$(Name)'

.azure-pipelines/windows-release/stage-pack-msix.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ jobs:
2020
Artifact: appxstore
2121
Suffix: -store
2222
Upload: true
23+
arm64:
24+
Name: arm64
25+
Artifact: appx
26+
Suffix:
27+
ShouldSign: true
28+
arm64_store:
29+
Name: arm64
30+
Artifact: appxstore
31+
Suffix: -store
32+
Upload: true
2333

2434
steps:
2535
- template: ./checkout.yml

.azure-pipelines/windows-release/stage-pack-nuget.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
Name: amd64
1616
win32:
1717
Name: win32
18+
arm64:
19+
Name: arm64
1820

1921
steps:
2022
- checkout: none

.azure-pipelines/windows-release/stage-sign.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
Name: win32
2020
amd64:
2121
Name: amd64
22+
arm64:
23+
Name: arm64
2224

2325
steps:
2426
- template: ./checkout.yml

.azure-pipelines/windows-steps.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ steps:
1919

2020
- script: python.bat -m test.pythoninfo
2121
displayName: 'Display build info'
22+
condition: and(succeeded(), variables['testRunPlatform'])
2223

2324
- script: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results.xml" --tempdir="$(Build.BinariesDirectory)\test"
2425
displayName: 'Tests'
26+
condition: and(succeeded(), variables['testRunPlatform'])
2527
env:
2628
PREFIX: $(Py_OutDir)\$(arch)
2729

@@ -32,4 +34,4 @@ steps:
3234
mergeTestResults: true
3335
testRunTitle: $(testRunTitle)
3436
platform: $(testRunPlatform)
35-
condition: succeededOrFailed()
37+
condition: and(succeededOrFailed(), variables['testRunPlatform'])
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for building and releasing Windows ARM64 packages.

PC/layout/main.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,13 @@ def _compile_one_py(src, dest, name, optimize, checked=True):
285285
log_warning("Failed to compile {}", src)
286286
return None
287287

288+
288289
# name argument added to address bpo-37641
289290
def _py_temp_compile(src, name, ns, dest_dir=None, checked=True):
290291
if not ns.precompile or src not in PY_FILES or src.parent in DATA_DIRS:
291292
return None
292293
dest = (dest_dir or ns.temp) / (src.stem + ".pyc")
293-
return _compile_one_py(
294-
src, dest, name, optimize=2, checked=checked
295-
)
294+
return _compile_one_py(src, dest, name, optimize=2, checked=checked)
296295

297296

298297
def _write_to_zip(zf, dest, src, ns, checked=True):
@@ -496,6 +495,13 @@ def main():
496495
parser.add_argument(
497496
"-b", "--build", metavar="dir", help="Specify the build directory", type=Path
498497
)
498+
parser.add_argument(
499+
"--arch",
500+
metavar="architecture",
501+
help="Specify the target architecture",
502+
type=str,
503+
default=None,
504+
)
499505
parser.add_argument(
500506
"--doc-build",
501507
metavar="dir",
@@ -587,6 +593,8 @@ def main():
587593
ns.doc_build = (Path.cwd() / ns.doc_build).resolve()
588594
if ns.include_cat and not ns.include_cat.is_absolute():
589595
ns.include_cat = (Path.cwd() / ns.include_cat).resolve()
596+
if not ns.arch:
597+
ns.arch = "amd64" if sys.maxsize > 2 ** 32 else "win32"
590598

591599
if ns.copy and not ns.copy.is_absolute():
592600
ns.copy = (Path.cwd() / ns.copy).resolve()
@@ -602,6 +610,7 @@ def main():
602610
Source: {ns.source}
603611
Build: {ns.build}
604612
Temp: {ns.temp}
613+
Arch: {ns.arch}
605614
606615
Copy to: {ns.copy}
607616
Zip to: {ns.zip}
@@ -613,6 +622,10 @@ def main():
613622
log_warning("Assuming --include-tcltk to support --include-idle")
614623
ns.include_tcltk = True
615624

625+
if ns.arch not in ("win32", "amd64", "arm32", "arm64"):
626+
log_error("--arch is not a valid value (win32, amd64, arm32, arm64)")
627+
return 4
628+
616629
try:
617630
generate_source_files(ns)
618631
files = list(get_layout(ns))

0 commit comments

Comments
 (0)