@@ -413,11 +413,19 @@ $KnownPythons = @{
413
413
URL = " https://www.nuget.org/api/v2/package/python/3.10.1" ;
414
414
SHA256 = " 987a0e446d68900f58297bc47dc7a235ee4640a49dace58bc9f573797d3a8b33" ;
415
415
};
416
+ AMD64_Embedded = @ {
417
+ URL = " https://www.python.org/ftp/python/3.10.1/python-3.10.1-embed-amd64.zip" ;
418
+ SHA256 = " 502670dcdff0083847abf6a33f30be666594e7e5201cd6fccd4a523b577403de" ;
419
+ };
416
420
ARM64 = @ {
417
421
URL = " https://www.nuget.org/api/v2/package/pythonarm64/3.10.1" ;
418
422
SHA256 = " 16becfccedf1269ff0b8695a13c64fac2102a524d66cecf69a8f9229a43b10d3" ;
419
423
};
420
- };
424
+ ARM64_Embedded = @ {
425
+ URL = " https://www.python.org/ftp/python/3.10.1/python-3.10.1-embed-arm64.zip" ;
426
+ SHA256 = " 1f9e215fe4e8f22a8e8fba1859efb1426437044fb3103ce85794630e3b511bc2" ;
427
+ };
428
+ }
421
429
}
422
430
423
431
$PythonModules = @ {
@@ -741,6 +749,10 @@ function Get-PythonPath([Hashtable] $Platform) {
741
749
return [IO.Path ]::Combine(" $BinaryCache \" , " Python$ ( $Platform.Architecture.CMakeName ) -$PythonVersion " )
742
750
}
743
751
752
+ function Get-EmbeddedPythonPath ([Hashtable ] $Platform ) {
753
+ return [IO.Path ]::Combine(" $BinaryCache \" , " EmbeddedPython$ ( $Platform.Architecture.CMakeName ) -$PythonVersion " )
754
+ }
755
+
744
756
function Get-PythonExecutable {
745
757
return [IO.Path ]::Combine((Get-PythonPath $BuildPlatform ), " tools" , " python.exe" )
746
758
}
@@ -749,6 +761,10 @@ function Get-PythonScriptsPath {
749
761
return [IO.Path ]::Combine((Get-PythonPath $BuildPlatform ), " tools" , " Scripts" )
750
762
}
751
763
764
+ function Get-EmbeddedPythonInstallDir () {
765
+ return [IO.Path ]::Combine(" $ImageRoot \" , " Program Files" , " Swift" , " Python-$PythonVersion " )
766
+ }
767
+
752
768
function Get-Syft {
753
769
return $KnownSyft [$SyftVersion ][$BuildArchName ]
754
770
}
@@ -1250,11 +1266,33 @@ function Get-Dependencies {
1250
1266
return $KnownPythons [$PythonVersion ].$ArchName
1251
1267
}
1252
1268
1269
+ function Get-KnownEmbeddedPython ([string ] $ArchName ) {
1270
+ if (-not $KnownPythons.ContainsKey ($PythonVersion )) {
1271
+ throw " Unknown python version: $PythonVersion "
1272
+ }
1273
+ if (-not $KnownPythons [$PythonVersion ].ContainsKey(" ${ArchName} _Embedded" )) {
1274
+ return $null
1275
+ }
1276
+ return $KnownPythons [$PythonVersion ][" ${ArchName} _Embedded" ]
1277
+ }
1278
+
1253
1279
function Install-Python ([string ] $ArchName ) {
1254
1280
$Python = Get-KnownPython $ArchName
1255
1281
DownloadAndVerify $Python.URL " $BinaryCache \Python$ArchName -$PythonVersion .zip" $Python.SHA256
1256
1282
if (-not $ToBatch ) {
1257
- Expand-ZipFile Python$ArchName - $PythonVersion.zip " $BinaryCache " Python$ArchName - $PythonVersion
1283
+ Expand-ZipFile " Python$ArchName -$PythonVersion .zip" " $BinaryCache " " Python$ArchName -$PythonVersion "
1284
+ }
1285
+ }
1286
+
1287
+ function Install-EmbeddedPython ([string ] $ArchName ) {
1288
+ $Python = Get-KnownEmbeddedPython $ArchName
1289
+ if ($null -eq $Python ) {
1290
+ Write-Output " Python $PythonVersion does not have an embeddable version."
1291
+ return
1292
+ }
1293
+ DownloadAndVerify $Python.URL " $BinaryCache \EmbeddedPython$ArchName -$PythonVersion .zip" $Python.SHA256
1294
+ if (-not $ToBatch ) {
1295
+ Expand-ZipFile " EmbeddedPython$ArchName -$PythonVersion .zip" " $BinaryCache " " EmbeddedPython$ArchName -$PythonVersion "
1258
1296
}
1259
1297
}
1260
1298
@@ -1305,6 +1343,7 @@ function Get-Dependencies {
1305
1343
}
1306
1344
1307
1345
Install-Python $HostArchName
1346
+ Install-EmbeddedPython $HostArchName
1308
1347
if ($IsCrossCompiling ) {
1309
1348
Install-Python $BuildArchName
1310
1349
}
@@ -2163,6 +2202,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
2163
2202
LLDB_PYTHON_EXE_RELATIVE_PATH = " python.exe" ;
2164
2203
LLDB_PYTHON_EXT_SUFFIX = " .pyd" ;
2165
2204
LLDB_PYTHON_RELATIVE_PATH = " lib/site-packages" ;
2205
+ LLDB_PYTHON_DLL_RELATIVE_PATH = " ../../../../Python-$PythonVersion " ;
2166
2206
LLDB_TABLEGEN = (Join-Path - Path $BuildTools - ChildPath " lldb-tblgen.exe" );
2167
2207
LLDB_TEST_MAKE = " $BinaryCache \GnuWin32Make-4.4.1\bin\make.exe" ;
2168
2208
LLVM_CONFIG_PATH = (Join-Path - Path $BuildTools - ChildPath " llvm-config.exe" );
@@ -2187,6 +2227,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
2187
2227
Python3_INCLUDE_DIR = " $PythonRoot \include" ;
2188
2228
Python3_LIBRARY = " $PythonRoot \libs\$PythonLibName .lib" ;
2189
2229
Python3_ROOT_DIR = $PythonRoot ;
2230
+ Python3_VERSION = $PythonVersion ;
2190
2231
SWIFT_TOOLCHAIN_VERSION = " ${ToolchainIdentifier} " ;
2191
2232
SWIFT_BUILD_SWIFT_SYNTAX = " YES" ;
2192
2233
SWIFT_CLANG_LOCATION = (Get-PinnedToolchainToolsDir );
@@ -3831,6 +3872,12 @@ function Install-HostToolchain() {
3831
3872
Copy-Item - Force `
3832
3873
- Path $SwiftDriver `
3833
3874
- Destination " $ ( $HostPlatform.ToolchainInstallRoot ) \usr\bin\swiftc.exe"
3875
+
3876
+ # Copy embeddable Python
3877
+ New-Item - Type Directory - Path " $ ( Get-EmbeddedPythonInstallDir ) " - ErrorAction Ignore | Out-Null
3878
+ Copy-Item - Force - Recurse `
3879
+ - Path " $ ( Get-EmbeddedPythonPath $HostPlatform ) \*" `
3880
+ - Destination " $ ( Get-EmbeddedPythonInstallDir ) "
3834
3881
}
3835
3882
3836
3883
function Build-Inspect ([Hashtable ] $Platform ) {
@@ -3903,6 +3950,7 @@ function Build-Installer([Hashtable] $Platform) {
3903
3950
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC ;
3904
3951
SWIFT_DOCC_BUILD = " $ ( Get-ProjectBinaryCache $HostPlatform DocC) \release" ;
3905
3952
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = " ${SourceCache} \swift-docc-render-artifact" ;
3953
+ PythonVersion = $PythonVersion
3906
3954
}
3907
3955
3908
3956
Invoke-IsolatingEnvVars {
0 commit comments