Skip to content

Commit 3a2b03f

Browse files
[windows] upgrade to Python 3.10 embeddable
1 parent 37ae8a2 commit 3a2b03f

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

utils/build.ps1

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ param
129129
[string] $PinnedSHA256 = "",
130130
[string] $PinnedVersion = "",
131131
[ValidatePattern('^\d+(\.\d+)*$')]
132-
[string] $PythonVersion = "3.9.10",
132+
[string] $PythonVersion = "3.10.1",
133133
[ValidatePattern("^r(?:[1-9]|[1-9][0-9])(?:[a-z])?$")]
134134
[string] $AndroidNDKVersion = "r27c",
135135
[ValidatePattern("^\d+\.\d+\.\d+(?:-\w+)?")]
@@ -321,14 +321,22 @@ $WiX = @{
321321
}
322322

323323
$KnownPythons = @{
324-
"3.9.10" = @{
324+
"3.10.1" = @{
325325
AMD64 = @{
326-
URL = "https://www.nuget.org/api/v2/package/python/3.9.10";
327-
SHA256 = "ac43b491e9488ac926ed31c5594f0c9409a21ecbaf99dc7a93f8c7b24cf85867";
326+
URL = "https://www.nuget.org/api/v2/package/python/3.10.1";
327+
SHA256 = "987a0e446d68900f58297bc47dc7a235ee4640a49dace58bc9f573797d3a8b33";
328+
};
329+
AMD64_Embedded = @{
330+
URL = "https://www.python.org/ftp/python/3.10.1/python-3.10.1-embed-amd64.zip";
331+
SHA256 = "502670dcdff0083847abf6a33f30be666594e7e5201cd6fccd4a523b577403de";
328332
};
329333
ARM64 = @{
330-
URL = "https://www.nuget.org/api/v2/package/pythonarm64/3.9.10";
331-
SHA256 = "429ada77e7f30e4bd8ff22953a1f35f98b2728e84c9b1d006712561785641f69";
334+
URL = "https://www.nuget.org/api/v2/package/pythonarm64/3.10.1";
335+
SHA256 = "16becfccedf1269ff0b8695a13c64fac2102a524d66cecf69a8f9229a43b10d3";
336+
};
337+
ARM64_Embedded = @{
338+
URL = "https://www.python.org/ftp/python/3.10.1/python-3.10.1-embed-arm64.zip";
339+
SHA256 = "1f9e215fe4e8f22a8e8fba1859efb1426437044fb3103ce85794630e3b511bc2";
332340
};
333341
}
334342
}
@@ -349,11 +357,6 @@ $PythonModules = @{
349357
SHA256 = "353815f59a7f64cdaca1c0307ee13558a0512f6db064e92fe833784f08539c7a";
350358
Dependencies = @();
351359
};
352-
"unittest2" = @{
353-
Version = "1.1.0";
354-
SHA256 = "22882a0e418c284e1f718a822b3b022944d53d2d908e1690b319a9d3eb2c0579";
355-
Dependencies = @("argparse", "six", "traceback2", "linecache2");
356-
};
357360
"argparse" = @{
358361
Version = "1.4.0";
359362
SHA256 = "c31647edb69fd3d465a847ea3157d37bed1f95f19760b11a47aa91c04b666314";
@@ -590,6 +593,10 @@ function Get-PythonPath([Hashtable] $Platform) {
590593
return [IO.Path]::Combine("$BinaryCache\", "Python$($Platform.Architecture.CMakeName)-$PythonVersion")
591594
}
592595

596+
function Get-EmbeddedPythonPath([Hashtable] $Platform) {
597+
return [IO.Path]::Combine("$BinaryCache\", "EmbeddedPython$($Platform.Architecture.CMakeName)-$PythonVersion")
598+
}
599+
593600
function Get-PythonExecutable {
594601
return [IO.Path]::Combine((Get-PythonPath $BuildPlatform), "tools", "python.exe")
595602
}
@@ -1067,11 +1074,26 @@ function Get-Dependencies {
10671074
return $KnownPythons[$PythonVersion].$ArchName
10681075
}
10691076

1077+
function Get-KnownEmbeddedPython([string] $ArchName) {
1078+
if (-not $KnownPythons.ContainsKey($PythonVersion)) {
1079+
throw "Unknown python version: $PythonVersion"
1080+
}
1081+
return $KnownPythons[$PythonVersion]["${ArchName}_Embedded"]
1082+
}
1083+
10701084
function Install-Python([string] $ArchName) {
10711085
$Python = Get-KnownPython $ArchName
10721086
DownloadAndVerify $Python.URL "$BinaryCache\Python$ArchName-$PythonVersion.zip" $Python.SHA256
10731087
if (-not $ToBatch) {
1074-
Expand-ZipFile Python$ArchName-$PythonVersion.zip "$BinaryCache" Python$ArchName-$PythonVersion
1088+
Expand-ZipFile "Python$ArchName-$PythonVersion.zip" "$BinaryCache" "Python$ArchName-$PythonVersion"
1089+
}
1090+
}
1091+
1092+
function Install-EmbeddedPython([string] $ArchName) {
1093+
$Python = Get-KnownEmbeddedPython $ArchName
1094+
DownloadAndVerify $Python.URL "$BinaryCache\EmbeddedPython$ArchName-$PythonVersion.zip" $Python.SHA256
1095+
if (-not $ToBatch) {
1096+
Expand-ZipFile "EmbeddedPython$ArchName-$PythonVersion.zip" "$BinaryCache" "EmbeddedPython$ArchName-$PythonVersion"
10751097
}
10761098
}
10771099

@@ -1119,11 +1141,11 @@ function Get-Dependencies {
11191141
if ($Test -contains "lldb") {
11201142
Install-PythonModule "psutil" # Required for testing LLDB
11211143
$env:Path = "$(Get-PythonScriptsPath);$env:Path" # For unit.exe
1122-
Install-PythonModule "unittest2" # Required for testing LLDB
11231144
}
11241145
}
11251146

11261147
Install-Python $HostArchName
1148+
Install-EmbeddedPython $HostArchName
11271149
if ($IsCrossCompiling) {
11281150
Install-Python $BuildArchName
11291151
}
@@ -3442,16 +3464,22 @@ function Install-HostToolchain() {
34423464

34433465
# Restructure _InternalSwiftScan (keep the original one for the installer)
34443466
Copy-Item -Force `
3445-
"$($HostPlatform.ToolchainInstallRoot)\usr\lib\swift\_InternalSwiftScan" `
3446-
"$($HostPlatform.ToolchainInstallRoot)\usr\include"
3467+
-Path "$($HostPlatform.ToolchainInstallRoot)\usr\lib\swift\_InternalSwiftScan" `
3468+
-Destination "$($HostPlatform.ToolchainInstallRoot)\usr\include"
34473469
Copy-Item -Force `
3448-
"$($HostPlatform.ToolchainInstallRoot)\usr\lib\swift\windows\_InternalSwiftScan.lib" `
3449-
"$($HostPlatform.ToolchainInstallRoot)\usr\lib"
3470+
-Path "$($HostPlatform.ToolchainInstallRoot)\usr\lib\swift\windows\_InternalSwiftScan.lib" `
3471+
-Destination "$($HostPlatform.ToolchainInstallRoot)\usr\lib"
34503472

34513473
# Switch to swift-driver
34523474
$SwiftDriver = ([IO.Path]::Combine((Get-ProjectBinaryCache $HostPlatform Driver), "bin", "swift-driver.exe"))
34533475
Copy-Item -Force $SwiftDriver "$($HostPlatform.ToolchainInstallRoot)\usr\bin\swift.exe"
34543476
Copy-Item -Force $SwiftDriver "$($HostPlatform.ToolchainInstallRoot)\usr\bin\swiftc.exe"
3477+
3478+
# Embed Python
3479+
Copy-Item -Force `
3480+
-Path "$(Get-EmbeddedPythonPath $HostPlatform)\*" `
3481+
-Destination "$($HostPlatform.ToolchainInstallRoot)\usr\bin" `
3482+
-Recurse
34553483
}
34563484

34573485
function Build-Inspect([Hashtable] $Platform) {

0 commit comments

Comments
 (0)