Skip to content

Commit 58a7c91

Browse files
authored
gh-115582 and gh-115545: Windows release build mixes up free-threaded files (#98)
1 parent ff37a1d commit 58a7c91

20 files changed

Lines changed: 450 additions & 460 deletions

windows-release/README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,27 @@ Without this, the build records will be lost after 30 days.
4040
The code signing certificate is stored in Azure Key Vault, and is authenticated using the
4141
variables in a Variable group called CPythonSign. The variable group is what triggers approvals.
4242
The group is at https://dev.azure.com/Python/cpython/_library?itemType=VariableGroups&view=VariableGroupView&variableGroupId=1&path=CPythonSign
43+
A second group called CPythonTestSign exists without approvals, but only has access to a test signing certificate.
44+
45+
The five variables in the Variable Group identify the Entra ID
46+
[App registration](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app) with access,
47+
and the name of the certificate to use.
48+
49+
* `KeyVaultApplication` - the "Application (client) ID" of the App registration
50+
* `KeyVaultDirectory` - the "Directory (tenant) ID" of the App registration
51+
* `KeyVaultSecret` - the current "Client secret" of the App registration
52+
* `KeyVaultUri` - the base `https://*.vault.azure.net/` URI of the Key Vault
53+
* `KeyVaultCertificateName` - the name of the certificate. This is not a secret
54+
55+
The Key Vault should be configured to use Azure role-based access control (soon to be the only option),
56+
and the App registration should have the "Key Vault Certificate User" and "Key Vault Crypto User" roles.
57+
The trusted owner of the Key Vault should have the "Owner" role, but the App registration should not.
4358

4459
To upload a new code signing certificate (which will be provided by the PSF),
45-
or to change to a new Azure Keyvault instance,
46-
see the documentation at https://github.com/vcsjones/AzureSignTool/blob/main/WALKTHROUGH.md.
60+
you need the certificate in encrypted .pfx format.
61+
This can then be uploaded directly through the Azure Portal into the Key Vault along with the passphrase.
62+
If reusing an existing Key Vault, upload it as a new version of the existing certificate.
63+
If it is uploaded as a new certificate, the Variable Group must be updated.
4764

4865
GPG signature generation uses a GPG key stored in the Secure Files library.
4966
This can be found at https://dev.azure.com/Python/cpython/_library?itemType=SecureFiles

windows-release/azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ stages:
145145
parameters:
146146
${{ if and(parameters.SigningCertificate, ne(parameters.SigningCertificate, 'Unsigned')) }}:
147147
SigningCertificate: ${{ parameters.SigningCertificate }}
148+
DoFreethreaded: ${{ parameters.DoFreethreaded }}
148149

149150
- stage: Layout
150151
displayName: Generate layouts
@@ -204,6 +205,7 @@ stages:
204205
ARM64TclTk: ${{ parameters.ARM64TclTk }}
205206
${{ if and(parameters.SigningCertificate, ne(parameters.SigningCertificate, 'Unsigned')) }}:
206207
SigningCertificate: ${{ parameters.SigningCertificate }}
208+
DoARM64: ${{ parameters.DoARM64}}
207209
DoFreethreaded: ${{ parameters.DoFreethreaded }}
208210

209211
- stage: Test_MSI

windows-release/build-steps-pgo.yml

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ parameters:
22
PGInstrument: false
33
PGRun: false
44
PGUpdate: false
5-
DoFreethreaded: false
65

76
steps:
87
- template: ./checkout.yml
@@ -23,21 +22,12 @@ steps:
2322
- ${{ if eq(parameters.PGInstrument, 'true') }}:
2423
- powershell: |
2524
$env:SigningCertificate = $null
26-
.\PCbuild\build.bat -v -p $(Platform) -c PGInstrument
25+
.\PCbuild\build.bat -v -p $(Platform) -c PGInstrument $(ExtraOptions)
2726
displayName: 'Run build'
2827
env:
2928
IncludeUwp: true
3029
Py_OutDir: '$(Build.BinariesDirectory)\bin'
3130
32-
- ${{ if eq(parameters.DoFreethreaded, 'true') }}:
33-
- powershell: |
34-
$env:SigningCertificate = $null
35-
.\PCbuild\build.bat -v -p $(Platform) -c PGInstrument --disable-gil
36-
displayName: 'Run free-threaded build'
37-
env:
38-
IncludeUwp: true
39-
Py_OutDir: '$(Build.BinariesDirectory)\bin'
40-
4131
- ${{ if ne(parameters.PGRun, 'true') }}:
4232
# Not running in this job, so we publish our entire build and object files
4333

@@ -70,21 +60,13 @@ steps:
7060
targetPath: '$(Build.BinariesDirectory)\bin\$(Arch)\instrumented'
7161

7262
- powershell: |
73-
& "$(Build.BinariesDirectory)\bin\$(Arch)\instrumented\python.exe" -m test --pgo
63+
$exe = (gci "$(Build.BinariesDirectory)\bin\$(Arch)\instrumented\$(PythonExePattern)" | select -First 1)
64+
& $exe -m test --pgo
7465
ignoreLASTEXITCODE: true
7566
displayName: 'Collect profile'
7667
env:
7768
PYTHONHOME: '$(Build.SourcesDirectory)'
7869
79-
- ${{ if eq(parameters.DoFreethreaded, 'true') }}:
80-
- powershell: |
81-
$exe = (gci "$(Build.BinariesDirectory)\bin\$(Arch)\instrumented\python3*t.exe" | select -First 1)
82-
& $exe -m test --pgo
83-
ignoreLASTEXITCODE: true
84-
displayName: 'Collect free-threaded profile'
85-
env:
86-
PYTHONHOME: '$(Build.SourcesDirectory)'
87-
8870
8971
- ${{ if ne(parameters.PGUpdate, 'true') }}:
9072
# Not finishing in this job, so publish the binaries
@@ -121,21 +103,12 @@ steps:
121103
122104
- powershell: |
123105
$env:SigningCertificate = $null
124-
.\PCbuild\build.bat -v -p $(Platform) -c PGUpdate
106+
.\PCbuild\build.bat -v -p $(Platform) -c PGUpdate $(ExtraOptions)
125107
displayName: 'Run build with PGO'
126108
env:
127109
IncludeUwp: true
128110
Py_OutDir: '$(Build.BinariesDirectory)\bin'
129111
130-
- ${{ if eq(parameters.DoFreethreaded, 'true') }}:
131-
- powershell: |
132-
$env:SigningCertificate = $null
133-
.\PCbuild\build.bat -v -p $(Platform) -c PGUpdate --disable-gil
134-
displayName: 'Run free-threaded build with PGO'
135-
env:
136-
IncludeUwp: true
137-
Py_OutDir: '$(Build.BinariesDirectory)\bin'
138-
139112
- powershell: |
140113
$kitroot = (gp 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\').KitsRoot10
141114
$tool = (gci -r "$kitroot\Bin\*\x64\signtool.exe" | sort FullName -Desc | select -First 1)

windows-release/build-steps.yml

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
parameters:
22
ShouldPGO: false
3-
DoFreethreaded: false
43

54
steps:
65
- template: ./checkout.yml
@@ -16,48 +15,24 @@ steps:
1615
Write-Host "##vso[build.addbuildtag]$($d.PythonVersion)-$(Name)"
1716
displayName: 'Extract version numbers'
1817

19-
- ${{ if eq(parameters.DoFreethreaded, 'true') }}:
20-
- powershell: |
21-
Write-Host "##vso[build.addbuildtag]freethreaded"
22-
Write-Host "##vso[build.addbuildtag]$(VersionText)-freethreaded"
23-
displayName: 'Add freethreaded tags'
24-
2518
- ${{ if eq(parameters.ShouldPGO, 'false') }}:
2619
- powershell: |
2720
$env:SigningCertificate = $null
28-
.\PCbuild\build.bat -v -p $(Platform) -c $(Configuration)
21+
.\PCbuild\build.bat -v -p $(Platform) -c $(Configuration) $(ExtraOptions)
2922
displayName: 'Run build'
3023
env:
3124
IncludeUwp: true
3225
Py_OutDir: '$(Build.BinariesDirectory)\bin'
3326
34-
- ${{ if eq(parameters.DoFreethreaded, 'true') }}:
35-
- powershell: |
36-
$env:SigningCertificate = $null
37-
.\PCbuild\build.bat -v -p $(Platform) -c $(Configuration) --disable-gil
38-
displayName: 'Run free-threaded build'
39-
env:
40-
IncludeUwp: true
41-
Py_OutDir: '$(Build.BinariesDirectory)\bin'
42-
4327
- ${{ if eq(parameters.ShouldPGO, 'true') }}:
4428
- powershell: |
4529
$env:SigningCertificate = $null
46-
.\PCbuild\build.bat -v -p $(Platform) --pgo
30+
.\PCbuild\build.bat -v -p $(Platform) --pgo $(ExtraOptions)
4731
displayName: 'Run build with PGO'
4832
env:
4933
IncludeUwp: true
5034
Py_OutDir: '$(Build.BinariesDirectory)\bin'
5135
52-
- ${{ if eq(parameters.DoFreethreaded, 'true') }}:
53-
- powershell: |
54-
$env:SigningCertificate = $null
55-
.\PCbuild\build.bat -v -p $(Platform) --pgo --disable-gil
56-
displayName: 'Run free-threaded build'
57-
env:
58-
IncludeUwp: true
59-
Py_OutDir: '$(Build.BinariesDirectory)\bin'
60-
6136
- powershell: |
6237
$kitroot = (gp 'HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots\').KitsRoot10
6338
$tool = (gci -r "$kitroot\Bin\*\x64\signtool.exe" | sort FullName -Desc | select -First 1)

windows-release/layout-command.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
1+
parameters:
2+
Binaries: $(Pipeline.Workspace)\bin_$(Name)
3+
Sources: $(Build.SourcesDirectory)
4+
Temp: $(Build.BinariesDirectory)\layout-temp
5+
Docs: $(Build.BinariesDirectory)\doc
6+
17
steps:
2-
- task: DownloadPipelineArtifact@1
8+
- download: current
9+
artifact: bin_$(HostArch)
310
displayName: 'Download artifact: bin_$(HostArch)'
411
condition: and(succeeded(), variables['HostArch'])
5-
inputs:
6-
artifactName: bin_$(HostArch)
7-
targetPath: $(Build.BinariesDirectory)\bin_$(HostArch)
12+
13+
- powershell: |
14+
Write-Host "##vso[task.setvariable variable=Python]${{ parameters.Binaries }}\python.exe"
15+
condition: and(succeeded(), not(variables['HostArch']))
16+
displayName: 'Set Python command'
17+
18+
- powershell: |
19+
Write-Host "##vso[task.setvariable variable=Python]$(Pipeline.Workspace)\bin_$(HostArch)\python.exe"
20+
condition: and(succeeded(), variables['HostArch'])
21+
displayName: 'Set Python command'
822

923
- powershell: >
10-
Write-Host (
11-
'##vso[task.setvariable variable=LayoutCmd]&
24+
$layout_cmd = '&
1225
"$(Python)"
1326
"{1}\PC\layout"
1427
-vv
1528
--source "{1}"
16-
--build "{0}\bin"
17-
--arch "$(Name)"
18-
--temp "{0}\layout-temp"
19-
--include-cat "{0}\bin\python.cat"
20-
--doc-build "{0}\doc"'
21-
-f ("$(Build.BinariesDirectory)", "$(Build.SourcesDirectory)")
22-
)
29+
--build "{0}"
30+
--arch "$(Arch)"
31+
--temp "{2}"
32+
--include-cat "{0}\python.cat"
33+
--doc-build "{3}"'
34+
-f ("${{ parameters.Binaries }}", "${{ parameters.Sources }}", "${{ parameters.Temp }}", "${{ parameters.Docs}}");
35+
Write-Host "##vso[task.setvariable variable=LayoutCmd]$layout_cmd";
36+
Write-Host "Setting LayoutCmd=$layout_cmd"
2337
displayName: 'Set LayoutCmd'

windows-release/libffi-build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ name: ${{ parameters.SourceTag }}_$(Date:yyyyMMdd)$(Rev:.rr)
2424

2525

2626
variables:
27-
- group: CPythonSign
27+
- ${{ if eq(parameters.SigningCertificate, 'PythonSoftwareFoundation') }}:
28+
- group: CPythonSign
29+
- ${{ if eq(parameters.SigningCertificate, 'TestSign') }}:
30+
- group: CPythonTestSign
2831
- name: IntDir
2932
value: '$(Build.BinariesDirectory)'
3033
- name: OutDir

0 commit comments

Comments
 (0)