@@ -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
}
@@ -1093,11 +1119,33 @@ function Get-Dependencies {
1093
1119
return $KnownPythons [$PythonVersion ].$ArchName
1094
1120
}
1095
1121
1122
+ function Get-KnownEmbeddedPython ([string ] $ArchName ) {
1123
+ if (-not $KnownPythons.ContainsKey ($PythonVersion )) {
1124
+ throw " Unknown python version: $PythonVersion "
1125
+ }
1126
+ if (-not $KnownPythons [$PythonVersion ].ContainsKey(" ${ArchName} _Embedded" )) {
1127
+ return $null
1128
+ }
1129
+ return $KnownPythons [$PythonVersion ][" ${ArchName} _Embedded" ]
1130
+ }
1131
+
1096
1132
function Install-Python ([string ] $ArchName ) {
1097
1133
$Python = Get-KnownPython $ArchName
1098
1134
DownloadAndVerify $Python.URL " $BinaryCache \Python$ArchName -$PythonVersion .zip" $Python.SHA256
1099
1135
if (-not $ToBatch ) {
1100
- Expand-ZipFile Python$ArchName - $PythonVersion.zip " $BinaryCache " Python$ArchName - $PythonVersion
1136
+ Expand-ZipFile " Python$ArchName -$PythonVersion .zip" " $BinaryCache " " Python$ArchName -$PythonVersion "
1137
+ }
1138
+ }
1139
+
1140
+ function Install-EmbeddedPython ([string ] $ArchName ) {
1141
+ $Python = Get-KnownEmbeddedPython $ArchName
1142
+ if ($Python -eq $null ) {
1143
+ Write-Output " Python $PythonVersion does not have an embeddable version."
1144
+ return
1145
+ }
1146
+ DownloadAndVerify $Python.URL " $BinaryCache \EmbeddedPython$ArchName -$PythonVersion .zip" $Python.SHA256
1147
+ if (-not $ToBatch ) {
1148
+ Expand-ZipFile " EmbeddedPython$ArchName -$PythonVersion .zip" " $BinaryCache " " EmbeddedPython$ArchName -$PythonVersion "
1101
1149
}
1102
1150
}
1103
1151
@@ -1148,6 +1196,7 @@ function Get-Dependencies {
1148
1196
}
1149
1197
1150
1198
Install-Python $HostArchName
1199
+ Install-EmbeddedPython $HostArchName
1151
1200
if ($IsCrossCompiling ) {
1152
1201
Install-Python $BuildArchName
1153
1202
}
@@ -3470,16 +3519,22 @@ function Install-HostToolchain() {
3470
3519
3471
3520
# Restructure _InternalSwiftScan (keep the original one for the installer)
3472
3521
Copy-Item - Force `
3473
- " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\lib\swift\_InternalSwiftScan" `
3474
- " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\include"
3522
+ - Path " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\lib\swift\_InternalSwiftScan" `
3523
+ - Destination " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\include"
3475
3524
Copy-Item - Force `
3476
- " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\lib\swift\windows\_InternalSwiftScan.lib" `
3477
- " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\lib"
3525
+ - Path " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\lib\swift\windows\_InternalSwiftScan.lib" `
3526
+ - Destination " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\lib"
3478
3527
3479
3528
# Switch to swift-driver
3480
3529
$SwiftDriver = ([IO.Path ]::Combine((Get-ProjectBinaryCache $HostPlatform Driver), " bin" , " swift-driver.exe" ))
3481
3530
Copy-Item - Force $SwiftDriver " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\bin\swift.exe"
3482
3531
Copy-Item - Force $SwiftDriver " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\bin\swiftc.exe"
3532
+
3533
+ # Copy embeddable Python
3534
+ New-Item - Type Directory - Path " $ ( Get-EmbeddedPythonInstallDir ) " - ErrorAction Ignore | Out-Null
3535
+ Copy-Item - Force - Recurse `
3536
+ - Path " $ ( Get-EmbeddedPythonPath $HostPlatform ) \*" `
3537
+ - Destination " $ ( Get-EmbeddedPythonInstallDir ) "
3483
3538
}
3484
3539
3485
3540
function Build-Inspect ([Hashtable ] $Platform ) {
@@ -3550,6 +3605,7 @@ function Build-Installer([Hashtable] $Platform) {
3550
3605
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC ;
3551
3606
SWIFT_DOCC_BUILD = " $ ( Get-ProjectBinaryCache $HostPlatform DocC) \release" ;
3552
3607
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = " ${SourceCache} \swift-docc-render-artifact" ;
3608
+ PythonRoot = " $ ( Get-EmbeddedPythonInstallDir ) "
3553
3609
}
3554
3610
3555
3611
Invoke-IsolatingEnvVars {
0 commit comments