Skip to content

Commit ea5e9b4

Browse files
[windows] add an option to install Embeddable Python in the toolchain installer
1 parent 949686f commit ea5e9b4

File tree

10 files changed

+88
-22
lines changed

10 files changed

+88
-22
lines changed

platforms/Windows/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
ArePackageCabsEmbedded=$(ArePackageCabsEmbedded);
8585
BaseReleaseDownloadUrl=$(BaseReleaseDownloadUrl);
8686
ImageRoot=$(ImageRoot);
87+
PythonVersion=$(PythonVersion);
8788
WindowsRuntimeARM64=$(WindowsRuntimeARM64);
8889
WindowsRuntimeX64=$(WindowsRuntimeX64);
8990
WindowsRuntimeX86=$(WindowsRuntimeX86);

platforms/Windows/SideBySideUpgradeStrategy.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<ExperimentalRTLUpgradeCode>{F9BA01C7-0C7C-4898-90BD-9D6BB308F0B3}</ExperimentalRTLUpgradeCode>
3030
<AndroidPlatformUpgradeCode>{313B9C1F-D5B5-4FED-B7E0-138F1EE6B26A}</AndroidPlatformUpgradeCode>
3131
<WindowsPlatformUpgradeCode>{01AFF1CF-A025-41B6-BCBC-728D794353FD}</WindowsPlatformUpgradeCode>
32+
<PythonUpgradeCode>{5FC42BA9-ABF5-4CCD-B93B-BDFED936BA37}</PythonUpgradeCode>
3233
</PropertyGroup>
3334

3435
<PropertyGroup Condition="'$(MajorMinorProductVersion)' == '0.0'">
@@ -71,6 +72,7 @@
7172
ExperimentalRTLUpgradeCode=$(ExperimentalRTLUpgradeCode);
7273
AndroidPlatformUpgradeCode=$(AndroidPlatformUpgradeCode);
7374
WindowsPlatformUpgradeCode=$(WindowsPlatformUpgradeCode);
75+
PythonUpgradeCode=$(PythonUpgradeCode);
7476
</DefineConstants>
7577
</PropertyGroup>
7678
</Project>

platforms/Windows/bundle/installer.wixproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<ProjectReference Include="..\cli\asserts\cli.asserts.wixproj" BindName="cli.asserts" />
2222
<ProjectReference Include="..\dbg\asserts\dbg.asserts.wixproj" BindName="dbg.asserts" />
2323
<ProjectReference Include="..\ide\asserts\ide.asserts.wixproj" BindName="ide.asserts" />
24+
<ProjectReference Include="..\python\python.wixproj" BindName="python" />
2425
</ItemGroup>
2526

2627
<ItemGroup Condition=" $(ToolchainVariants.Contains('noasserts')) ">

platforms/Windows/bundle/installer.wxs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<Variable Name="OptionsInstallBLD" Value="1" />
3232
<Variable Name="OptionsInstallCLI" bal:Overridable="yes" Persisted="yes" Value="1" />
3333
<Variable Name="OptionsInstallDBG" bal:Overridable="yes" Persisted="yes" Value="1" />
34+
<Variable Name="OptionsInstallEmbeddedPython" bal:Overridable="yes" Persisted="yes" Value="1" />
3435
<Variable Name="OptionsInstallIDE" bal:Overridable="yes" Persisted="yes" Value="1" />
3536
<Variable Name="OptionsInstallRTL" Value="1" />
3637

@@ -134,6 +135,13 @@
134135
</MsiPackage>
135136
<?endif?>
136137

138+
<MsiPackage
139+
SourceFile="!(bindpath.python)\python.msi"
140+
InstallCondition="OptionsInstallEmbeddedPython = 1 and OptionsInstallDBG = 1"
141+
DownloadUrl="$(BaseReleaseDownloadUrl)/{2}">
142+
<MsiProperty Name="INSTALLROOT" Value="[InstallRoot]" />
143+
</MsiPackage>
144+
137145
<MsiPackage
138146
SourceFile="!(bindpath.ide.asserts)\ide.asserts.msi"
139147
InstallCondition="OptionsInstallIDE = 1 and OptionsInstallAssertsToolchain = 1"

platforms/Windows/bundle/theme.xml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<Font Id="2" Height="-18" Weight="500" Foreground="graytext">Segoe UI</Font>
1010
<Font Id="3" Height="-12" Weight="500" Foreground="windowtext" Background="window">Segoe UI</Font>
1111

12-
<Window Width="630" Height="500" HexStyle="100a0000" FontId="0" Caption="#(loc.Caption)">
13-
<ImageControl X="0" Y="0" Width="181" Height="500" ImageFile="swift_side.png"/>
12+
<Window Width="630" Height="530" HexStyle="100a0000" FontId="0" Caption="#(loc.Caption)">
13+
<ImageControl X="0" Y="0" Width="181" Height="530" ImageFile="swift_side.png"/>
1414
<Label X="192" Y="11" Width="-11" Height="32" FontId="1" DisablePrefix="yes">#(loc.Title)</Label>
1515

1616
<Page Name="Help">
@@ -59,24 +59,24 @@
5959
<Checkbox Name="OptionsInstallBLD" X="192" Y="111" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="0">#(loc.Bld_ProductName)</Checkbox>
6060
<Checkbox Name="OptionsInstallCLI" X="192" Y="129" Width="-11" Height="17" TabStop="yes" FontId="3">#(loc.Cli_ProductName)</Checkbox>
6161
<Checkbox Name="OptionsInstallDBG" X="192" Y="147" Width="-11" Height="17" TabStop="yes" FontId="3">#(loc.Dbg_ProductName)</Checkbox>
62-
<Checkbox Name="OptionsInstallIDE" X="192" Y="165" Width="-11" Height="17" TabStop="yes" FontId="3">#(loc.Ide_ProductName)</Checkbox>
63-
<Checkbox Name="OptionsInstallRTL" X="192" Y="183" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="0">#(loc.Rtl_ProductName)</Checkbox>
64-
<Checkbox Name="OptionsInstallWindowsPlatform" X="192" Y="201" Width="-11" Height="17" TabStop="yes" FontId="3">#(loc.Plt_ProductName_Windows)</Checkbox>
65-
<Checkbox Name="OptionsInstallWindowsSDKAMD64" X="210" Y="219" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform">#(loc.Sdk_ProductName_Windows_amd64)</Checkbox>
66-
<Checkbox Name="OptionsInstallWindowsRedistAMD64" X="228" Y="237" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform AND OptionsInstallWindowsSDKAMD64">#(loc.Redist_amd64)</Checkbox>
67-
<Checkbox Name="OptionsInstallWindowsSDKARM64" X="210" Y="255" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform">#(loc.Sdk_ProductName_Windows_arm64)</Checkbox>
68-
<Checkbox Name="OptionsInstallWindowsRedistARM64" X="228" Y="273" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform AND OptionsInstallWindowsSDKARM64">#(loc.Redist_arm64)</Checkbox>
69-
<Checkbox Name="OptionsInstallWindowsSDKX86" X="210" Y="291" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform">#(loc.Sdk_ProductName_Windows_x86)</Checkbox>
70-
<Checkbox Name="OptionsInstallWindowsRedistX86" X="228" Y="309" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform AND OptionsInstallWindowsSDKX86">#(loc.Redist_x86)</Checkbox>
71-
<Checkbox Name="OptionsInstallAndroidPlatform" X="192" Y="327" Width="-11" Height="17" TabStop="yes" FontId="3">#(loc.Plt_ProductName_Android)</Checkbox>
72-
<Checkbox Name="OptionsInstallAndroidSDKARM64" X="210" Y="345" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_arm64)</Checkbox>
73-
<Checkbox Name="OptionsInstallAndroidSDKAMD64" X="210" Y="363" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_amd64)</Checkbox>
74-
<Checkbox Name="OptionsInstallAndroidSDKARM" X="210" Y="381" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_armv7)</Checkbox>
75-
<Checkbox Name="OptionsInstallAndroidSDKX86" X="210" Y="399" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_x86)</Checkbox>
76-
<Checkbox Name="OptionsInstallToolchain" X="192" Y="417" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="0">#(loc.Toolchain_ProductName)</Checkbox>
77-
<Checkbox Name="OptionsInstallAssertsToolchain" X="210" Y="435" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsIncludeNoAsserts and OptionsInstallNoAssertsToolchain">#(loc.Asserts_Toolchain_ProductName)</Checkbox>
78-
<Checkbox Name="OptionsInstallNoAssertsToolchain" X="210" Y="453" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsIncludeNoAsserts and OptionsInstallAssertsToolchain">#(loc.NoAsserts_Toolchain_ProductName)</Checkbox>
79-
62+
<Checkbox Name="OptionsInstallEmbeddedPython" X="210" Y="165" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallDBG">#(loc.EmbeddedPython_ProductName)</Checkbox>
63+
<Checkbox Name="OptionsInstallIDE" X="192" Y="183" Width="-11" Height="17" TabStop="yes" FontId="3">#(loc.Ide_ProductName)</Checkbox>
64+
<Checkbox Name="OptionsInstallRTL" X="192" Y="201" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="0">#(loc.Rtl_ProductName)</Checkbox>
65+
<Checkbox Name="OptionsInstallWindowsPlatform" X="192" Y="219" Width="-11" Height="17" TabStop="yes" FontId="3">#(loc.Plt_ProductName_Windows)</Checkbox>
66+
<Checkbox Name="OptionsInstallWindowsSDKAMD64" X="210" Y="237" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform">#(loc.Sdk_ProductName_Windows_amd64)</Checkbox>
67+
<Checkbox Name="OptionsInstallWindowsRedistAMD64" X="228" Y="255" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform AND OptionsInstallWindowsSDKAMD64">#(loc.Redist_amd64)</Checkbox>
68+
<Checkbox Name="OptionsInstallWindowsSDKARM64" X="210" Y="273" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform">#(loc.Sdk_ProductName_Windows_arm64)</Checkbox>
69+
<Checkbox Name="OptionsInstallWindowsRedistARM64" X="228" Y="291" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform AND OptionsInstallWindowsSDKARM64">#(loc.Redist_arm64)</Checkbox>
70+
<Checkbox Name="OptionsInstallWindowsSDKX86" X="210" Y="309" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform">#(loc.Sdk_ProductName_Windows_x86)</Checkbox>
71+
<Checkbox Name="OptionsInstallWindowsRedistX86" X="228" Y="327" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallWindowsPlatform AND OptionsInstallWindowsSDKX86">#(loc.Redist_x86)</Checkbox>
72+
<Checkbox Name="OptionsInstallAndroidPlatform" X="192" Y="345" Width="-11" Height="17" TabStop="yes" FontId="3">#(loc.Plt_ProductName_Android)</Checkbox>
73+
<Checkbox Name="OptionsInstallAndroidSDKARM64" X="210" Y="363" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_arm64)</Checkbox>
74+
<Checkbox Name="OptionsInstallAndroidSDKAMD64" X="210" Y="381" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_amd64)</Checkbox>
75+
<Checkbox Name="OptionsInstallAndroidSDKARM" X="210" Y="399" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_armv7)</Checkbox>
76+
<Checkbox Name="OptionsInstallAndroidSDKX86" X="210" Y="417" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_x86)</Checkbox>
77+
<Checkbox Name="OptionsInstallToolchain" X="192" Y="435" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="0">#(loc.Toolchain_ProductName)</Checkbox>
78+
<Checkbox Name="OptionsInstallAssertsToolchain" X="210" Y="453" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsIncludeNoAsserts and OptionsInstallNoAssertsToolchain">#(loc.Asserts_Toolchain_ProductName)</Checkbox>
79+
<Checkbox Name="OptionsInstallNoAssertsToolchain" X="210" Y="471" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsIncludeNoAsserts and OptionsInstallAssertsToolchain">#(loc.NoAsserts_Toolchain_ProductName)</Checkbox>
8080
<Button Name="OptionsOkButton" X="-91" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">
8181
<Text>#(loc.OptionsOkButton)</Text>
8282
<ChangePageAction Page="Install" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project Sdk="WixToolset.Sdk/4.0.5">
2+
<PropertyGroup>
3+
<OutputName>python</OutputName>
4+
</PropertyGroup>
5+
</Project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2+
<?define PythonRoot = "$(ImageRoot)\Python-$(PythonVersion)"?>
3+
<?if $(ProductArchitecture) = "arm64"?>
4+
<?define ArchSuffix = "-arm64"?>
5+
<?else?>
6+
<?define ArchSuffix = ""?>
7+
<?endif?>
8+
9+
<Package
10+
Language="1033"
11+
Manufacturer="!(loc.ManufacturerName)"
12+
Name="!(loc.EmbeddedPython_ProductName)"
13+
UpgradeCode="$(PythonUpgradeCode)"
14+
Version="$(NonSemVerProductVersion)"
15+
Scope="$(PackageScope)">
16+
17+
<Media Id="1" Cabinet="python.cab" EmbedCab="$(ArePackageCabsEmbedded)" />
18+
19+
<WixVariable Id="SideBySidePackageUpgradeCode" Value="$(PythonUpgradeCode)" />
20+
<FeatureGroupRef Id="SideBySideUpgradeStrategy" />
21+
22+
<ComponentGroup Id="EmbeddedPython" Directory="Python">
23+
<Files Include="$(PythonRoot)/**" />
24+
</ComponentGroup>
25+
26+
<ComponentGroup Id="EmbeddedPythonLicense">
27+
<Component Directory="python_licenses">
28+
<File Source="$(PythonRoot)\LICENSE.txt" />
29+
</Component>
30+
</ComponentGroup>
31+
32+
<Feature Id="EmbeddedPython" AllowAbsent="no" Title="$(VariantProductName)">
33+
<ComponentGroupRef Id="EmbeddedPython" />
34+
<ComponentGroupRef Id="EmbeddedPythonLicense" />
35+
</Feature>
36+
</Package>
37+
</Wix>

platforms/Windows/readme.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The bundle authoring (in `installer.wxs`) drives optional install directory and
3434
| InstallRoot | A formatted string variable that specifies the installation root directory. The default value specified in `installer.wxs` should match the equivalent `INSTALLROOT` authoring in `shared.wxs`. The bundle variable is passed to each `MsiPackage` so overwrites the default directory authored in the MSI packages -- but keeping them in sync avoids the confusion if the default directory should change. |
3535
| OptionsInstallCLI | Controls whether command-line tools will be installed. |
3636
| OptionsInstallDBG | Controls whether debugging tools will be installed. |
37+
| OptionsInstallEmbeddedPython | Controls whether embeddable Python will be installed. |
3738
| OptionsInstallIDE | Controls whether IDE integration tools will be installed. |
3839
| OptionsInstallUtilties | Controls whether additional utilities will be installed. |
3940
| OptionsInstallAndroidPlatform | Controls whether the Android platform will be installed. |
@@ -177,6 +178,7 @@ To support the three architecture flavors of the SDK and RTL MSI packages, you n
177178
| MSBuild property | Description |
178179
| ---------------- | ----------- |
179180
| ImageRoot | Path to the root of the installed Swift image to package |
181+
| PythonVersion | Version of the Embeddable Python to package |
180182
| Platforms | Semicolon delimited list of platforms to package (android;windows) |
181183
| AndroidArchitectures | Semicolon delimited list of architectures the Android platform supports (aarch54;armv7;i686;x86_64) |
182184
| ToolchainVariants | Semicolon delimited list of toolchain variants to package (assert;noassert) |
@@ -194,10 +196,11 @@ msbuild %SourceRoot%\swift-installer-scripts\platforms\Windows\bundle\installer.
194196
-p:Configuration=Release ^
195197
-p:BaseOutputPath=%PackageRoot%\online\ ^
196198
-p:ImageRoot=%ImageRoot%\Program Files\Swift ^
199+
-p:PythonVersion=3.10.1 ^
197200
-p:Platforms="android;windows" ^
198201
-p:AndroidArchitectures="aarch64;armv7;i686;x86_64" ^
199202
-p:WindowsArchitectures="aarch64;i686;x86_64" ^
200-
-p:WindowsRuntimeARM64=%ImageRoot%\Prograam Files (Arm64)\Swift\Runtimes\0.0.0 ^
203+
-p:WindowsRuntimeARM64=%ImageRoot%\Program Files (Arm64)\Swift\Runtimes\0.0.0 ^
201204
-p:WindowsRuntimeX64=%ImageRoot%\Program Files\Swift\Runtimes\0.0.0 ^
202205
-p:WindowsRuntimeX86=%ImageRoot%\Program Files (x86)\Swift\Runtimes\0.0.0
203206
```
@@ -245,7 +248,7 @@ Note that these GUIDs are substituted at bind time so they skip the normal valid
245248

246249
| Property | Description |
247250
| -------- | ----------- |
248-
| BldAssertsUpgradeCode, BldNoAssertsUpgradeCode, CliAssertsUpgradeCode, CliNoAssertsUpgradeCode, DbgAssertsUpgradeCode, DbgNoAssertsUpgradeCode, IdeUpgradeCode, IdeNoUpgradeCode, RtlUpgradeCode, WindowsSDKUpgradeCode, AndroidSDKUpgradeCode | Upgrade codes for individual packages. Packages keep the same upgrade codes "forever" because MSI lets you specify version ranges for upgrades, which you can find in `shared/shared.wxs`. |
251+
| BldAssertsUpgradeCode, BldNoAssertsUpgradeCode, CliAssertsUpgradeCode, CliNoAssertsUpgradeCode, DbgAssertsUpgradeCode, DbgNoAssertsUpgradeCode, IdeUpgradeCode, IdeNoUpgradeCode, RtlUpgradeCode, WindowsSDKUpgradeCode, AndroidSDKUpgradeCode, PythonUpgradeCode | Upgrade codes for individual packages. Packages keep the same upgrade codes "forever" because MSI lets you specify version ranges for upgrades, which you can find in `shared/shared.wxs`. |
249252
| BundleUpgradeCode | Upgrade codes for the bundle. Bundles don't support upgrade version ranges, so the bundle upgrade code must change for every minor version _and_ stay the same for the entire lifetime of that minor version (e.g., v5.10.0 through v5.10.9999). You can keep the history of upgrade codes using a condition like `Condition="'$(MajorMinorProductVersion)' == '5.10'` or just replace BundleUpgradeCode when forking to a new minor version. |
250253

251254

platforms/Windows/shared/shared.wxs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
</DirectoryRef>
3636
</Fragment>
3737

38+
<Fragment>
39+
<DirectoryRef Id="INSTALLROOT">
40+
<Directory Id="Python" Name="Python-$(PythonVersion)" >
41+
<Directory Id="python_licenses" Name="licenses" />
42+
</Directory>
43+
</DirectoryRef>
44+
</Fragment>
45+
3846
<Fragment>
3947
<DirectoryRef Id="INSTALLROOT">
4048
<Directory Name="Toolchains">

platforms/Windows/shared/swift.en-us.wxl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<String Id="Dbg_ProductName" Value="Swift Debugging Tools" />
1212
<String Id="DbgAsserts_ProductName" Value="Swift Debugging Tools (Asserts)" />
1313
<String Id="DbgNoAsserts_ProductName" Value="Swift Debugging Tools (NoAsserts)" />
14+
<String Id="EmbeddedPython_ProductName" Value="Embedded Python" />
1415
<String Id="Ide_ProductName" Value="Swift IDE Integration Tools" />
1516
<String Id="IdeAsserts_ProductName" Value="Swift IDE Integration Tools (Asserts)" />
1617
<String Id="IdeNoAsserts_ProductName" Value="Swift IDE Integration Tools (NoAsserts)" />

0 commit comments

Comments
 (0)