Skip to content

Commit 191faf5

Browse files
[windows] add python msi build step
1 parent 2149731 commit 191faf5

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

utils/build.ps1

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ param
164164

165165
# Dependencies
166166
[ValidatePattern('^\d+(\.\d+)*$')]
167-
[string] $PythonVersion = "3.10.1",
167+
[string] $PythonVersion = "3.11.9",
168168

169169
# Toolchain Version Info
170170
[string] $ProductVersion = "0.0.0",
@@ -419,7 +419,25 @@ $KnownPythons = @{
419419
URL = "https://www.nuget.org/api/v2/package/pythonarm64/3.10.1";
420420
SHA256 = "16becfccedf1269ff0b8695a13c64fac2102a524d66cecf69a8f9229a43b10d3";
421421
};
422+
Source = @{
423+
URL = "https://www.python.org/ftp/python/3.10.1/Python-3.10.1.tgz";
424+
SHA256 = "b76117670e7c5064344b9c138e141a377e686b9063f3a8a620ff674fa8ec90d3"
425+
};
422426
};
427+
"3.11.9" = @{
428+
AMD64 = @{
429+
URL = "https://www.nuget.org/api/v2/package/python/3.11.9";
430+
SHA256 = "9283876d58c017e0e846f95b490da3bca0fc0a6ee1134b2870677cfb7eec3c67";
431+
};
432+
ARM64 = @{
433+
URL = "https://www.nuget.org/api/v2/package/pythonarm64/3.11.9";
434+
SHA256 = "2f5b3bee38850fdde1b44227a23b8130d329839558376d2eb11099ce2b2cc33c";
435+
};
436+
Source = @{
437+
URL = "https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz";
438+
SHA256 = "e7de3240a8bc2b1e1ba5c81bf943f06861ff494b69fda990ce2722a504c6153d";
439+
}
440+
}
423441
}
424442

425443
$PythonModules = @{
@@ -743,6 +761,10 @@ function Get-PythonPath([Hashtable] $Platform) {
743761
return [IO.Path]::Combine("$BinaryCache\", "Python$($Platform.Architecture.CMakeName)-$PythonVersion")
744762
}
745763

764+
function Get-PythonSourcePath() {
765+
return [IO.Path]::Combine("$BinaryCache\", "Python-$PythonVersion-Source")
766+
}
767+
746768
function Get-PythonExecutable {
747769
return [IO.Path]::Combine((Get-PythonPath $BuildPlatform), "tools", "python.exe")
748770
}
@@ -1268,6 +1290,15 @@ function Get-Dependencies {
12681290
}
12691291
}
12701292

1293+
function Install-PythonSource() {
1294+
$PythonSource = $KnownPythons[$PythonVersion]["Source"]
1295+
$Destination = Get-PythonSourcePath
1296+
New-Item -ItemType Directory -ErrorAction Ignore -Path $Destination | Out-Null
1297+
$Source = "$BinaryCache\Python-$PythonVersion-Source.tgz"
1298+
DownloadAndVerify $PythonSource.URL $Source $PythonSource.SHA256
1299+
tar -xvf $Source -C $Destination | Out-Null
1300+
}
1301+
12711302
function Install-PIPIfNeeded {
12721303
try {
12731304
Invoke-Program -Silent "$(Get-PythonExecutable)" -m pip
@@ -1322,6 +1353,7 @@ function Get-Dependencies {
13221353
Install-Python $BuildArchName
13231354
}
13241355
Install-PythonModules
1356+
Install-PythonSource
13251357

13261358
if ($SkipBuild -and $SkipPackaging) { return }
13271359

@@ -4039,6 +4071,16 @@ function Build-Installer([Hashtable] $Platform) {
40394071
Build-WiXProject bundle\installer.wixproj -Platform $Platform -Bundle -Properties $Properties
40404072
}
40414073

4074+
function Build-PythonInstaller([Hashtable] $Platform) {
4075+
Invoke-IsolatingEnvVars {
4076+
Invoke-VsDevShell $Platform
4077+
4078+
Push-Location "$(Get-PythonSourcePath)\Tools\msi"
4079+
Start-Process -Wait -WindowStyle Hidden -FilePath "buildrelease.bat" -ArgumentList @("-${Platform.Architecture.ShortName}", "-b", "-D", "--skip-zip", "--skip-nuget")
4080+
Pop-Location
4081+
}
4082+
}
4083+
40424084
function Copy-BuildArtifactsToStage([Hashtable] $Platform) {
40434085
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\*.cab" $Stage
40444086
Copy-File "$BinaryCache\$($Platform.Triple)\installer\Release\$($Platform.Architecture.VSName)\*.msi" $Stage
@@ -4360,6 +4402,7 @@ if (-not $SkipBuild) {
43604402
}
43614403

43624404
if (-not $SkipPackaging) {
4405+
Invoke-BuildStep Build-PythonInstaller $HostPlatform
43634406
Invoke-BuildStep Build-Installer $HostPlatform
43644407
}
43654408

0 commit comments

Comments
 (0)