@@ -332,6 +332,24 @@ $KnownPythons = @{
332
332
URL = " https://www.nuget.org/api/v2/package/pythonarm64/3.9.10" ;
333
333
SHA256 = " 429ada77e7f30e4bd8ff22953a1f35f98b2728e84c9b1d006712561785641f69" ;
334
334
};
335
+ };
336
+ " 3.10.1" = @ {
337
+ AMD64 = @ {
338
+ URL = " https://www.nuget.org/api/v2/package/python/3.10.1" ;
339
+ SHA256 = " 987a0e446d68900f58297bc47dc7a235ee4640a49dace58bc9f573797d3a8b33" ;
340
+ };
341
+ AMD64_Embedded = @ {
342
+ URL = " https://www.python.org/ftp/python/3.10.1/python-3.10.1-embed-amd64.zip" ;
343
+ SHA256 = " 502670dcdff0083847abf6a33f30be666594e7e5201cd6fccd4a523b577403de" ;
344
+ };
345
+ ARM64 = @ {
346
+ URL = " https://www.nuget.org/api/v2/package/pythonarm64/3.10.1" ;
347
+ SHA256 = " 16becfccedf1269ff0b8695a13c64fac2102a524d66cecf69a8f9229a43b10d3" ;
348
+ };
349
+ ARM64_Embedded = @ {
350
+ URL = " https://www.python.org/ftp/python/3.10.1/python-3.10.1-embed-arm64.zip" ;
351
+ SHA256 = " 1f9e215fe4e8f22a8e8fba1859efb1426437044fb3103ce85794630e3b511bc2" ;
352
+ };
335
353
}
336
354
}
337
355
@@ -597,6 +615,10 @@ function Get-PythonPath([Hashtable] $Platform) {
597
615
return [IO.Path ]::Combine(" $BinaryCache \" , " Python$ ( $Platform.Architecture.CMakeName ) -$PythonVersion " )
598
616
}
599
617
618
+ function Get-EmbeddedPythonPath ([Hashtable ] $Platform ) {
619
+ return [IO.Path ]::Combine(" $BinaryCache \" , " EmbeddedPython$ ( $Platform.Architecture.CMakeName ) -$PythonVersion " )
620
+ }
621
+
600
622
function Get-PythonExecutable {
601
623
return [IO.Path ]::Combine((Get-PythonPath $BuildPlatform ), " tools" , " python.exe" )
602
624
}
@@ -605,6 +627,10 @@ function Get-PythonScriptsPath {
605
627
return [IO.Path ]::Combine((Get-PythonPath $BuildPlatform ), " tools" , " Scripts" )
606
628
}
607
629
630
+ function Get-EmbeddedPythonInstallDir () {
631
+ return [IO.Path ]::Combine(" $ImageRoot \" , " Program Files" , " Swift" , " Python-$PythonVersion " )
632
+ }
633
+
608
634
function Get-Syft {
609
635
return $KnownSyft [$SyftVersion ][$BuildArchName ]
610
636
}
@@ -1098,11 +1124,33 @@ function Get-Dependencies {
1098
1124
return $KnownPythons [$PythonVersion ].$ArchName
1099
1125
}
1100
1126
1127
+ function Get-KnownEmbeddedPython ([string ] $ArchName ) {
1128
+ if (-not $KnownPythons.ContainsKey ($PythonVersion )) {
1129
+ throw " Unknown python version: $PythonVersion "
1130
+ }
1131
+ if (-not $KnownPythons [$PythonVersion ].ContainsKey(" ${ArchName} _Embedded" )) {
1132
+ return $null
1133
+ }
1134
+ return $KnownPythons [$PythonVersion ][" ${ArchName} _Embedded" ]
1135
+ }
1136
+
1101
1137
function Install-Python ([string ] $ArchName ) {
1102
1138
$Python = Get-KnownPython $ArchName
1103
1139
DownloadAndVerify $Python.URL " $BinaryCache \Python$ArchName -$PythonVersion .zip" $Python.SHA256
1104
1140
if (-not $ToBatch ) {
1105
- Expand-ZipFile Python$ArchName - $PythonVersion.zip " $BinaryCache " Python$ArchName - $PythonVersion
1141
+ Expand-ZipFile " Python$ArchName -$PythonVersion .zip" " $BinaryCache " " Python$ArchName -$PythonVersion "
1142
+ }
1143
+ }
1144
+
1145
+ function Install-EmbeddedPython ([string ] $ArchName ) {
1146
+ $Python = Get-KnownEmbeddedPython $ArchName
1147
+ if ($Python -eq $null ) {
1148
+ Write-Output " Python $PythonVersion does not have an embeddable version."
1149
+ return
1150
+ }
1151
+ DownloadAndVerify $Python.URL " $BinaryCache \EmbeddedPython$ArchName -$PythonVersion .zip" $Python.SHA256
1152
+ if (-not $ToBatch ) {
1153
+ Expand-ZipFile " EmbeddedPython$ArchName -$PythonVersion .zip" " $BinaryCache " " EmbeddedPython$ArchName -$PythonVersion "
1106
1154
}
1107
1155
}
1108
1156
@@ -1153,6 +1201,7 @@ function Get-Dependencies {
1153
1201
}
1154
1202
1155
1203
Install-Python $HostArchName
1204
+ Install-EmbeddedPython $HostArchName
1156
1205
if ($IsCrossCompiling ) {
1157
1206
Install-Python $BuildArchName
1158
1207
}
@@ -3528,6 +3577,12 @@ function Install-HostToolchain() {
3528
3577
Copy-Item - Force `
3529
3578
- Path $SwiftDriver `
3530
3579
- Destination " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\bin\swiftc.exe"
3580
+
3581
+ # Copy embeddable Python
3582
+ New-Item - Type Directory - Path " $ ( Get-EmbeddedPythonInstallDir ) " - ErrorAction Ignore | Out-Null
3583
+ Copy-Item - Force - Recurse `
3584
+ - Path " $ ( Get-EmbeddedPythonPath $HostPlatform ) \*" `
3585
+ - Destination " $ ( Get-EmbeddedPythonInstallDir ) "
3531
3586
}
3532
3587
3533
3588
function Build-Inspect ([Hashtable ] $Platform ) {
@@ -3598,6 +3653,7 @@ function Build-Installer([Hashtable] $Platform) {
3598
3653
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC ;
3599
3654
SWIFT_DOCC_BUILD = " $ ( Get-ProjectBinaryCache $HostPlatform DocC) \release" ;
3600
3655
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = " ${SourceCache} \swift-docc-render-artifact" ;
3656
+ PythonRoot = " $ ( Get-EmbeddedPythonInstallDir ) "
3601
3657
}
3602
3658
3603
3659
Invoke-IsolatingEnvVars {
0 commit comments