Skip to content

Commit 66022f0

Browse files
[windows] add an option to install Embeddable Python in the toolchain installer
1 parent 73d91f7 commit 66022f0

File tree

11 files changed

+201
-5
lines changed

11 files changed

+201
-5
lines changed

platforms/Windows/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
ArePackageCabsEmbedded=$(ArePackageCabsEmbedded);
8282
BaseReleaseDownloadUrl=$(BaseReleaseDownloadUrl);
8383
ImageRoot=$(ImageRoot);
84+
PythonVersion=$(PythonVersion);
8485
WindowsRuntimeARM64=$(WindowsRuntimeARM64);
8586
WindowsRuntimeX64=$(WindowsRuntimeX64);
8687
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\asserts\python.wixproj" BindName="python" />
2425
</ItemGroup>
2526

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

platforms/Windows/bundle/installer.wxs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@
141141
</MsiPackage>
142142
<?endif?>
143143

144+
<MsiPackage
145+
SourceFile="!(bindpath.python)\python.msi"
146+
InstallCondition="OptionsInstallEmbeddedPython = 1"
147+
DownloadUrl="$(BaseReleaseDownloadUrl)/{2}">
148+
<MsiProperty Name="INSTALLROOT" Value="[InstallRoot]" />
149+
</MsiPackage>
150+
144151
<MsiPackage
145152
SourceFile="!(bindpath.ide.asserts)\ide.asserts.msi"
146153
InstallCondition="OptionsInstallIDE = 1 and OptionsInstallAssertsToolchain = 1"

platforms/Windows/bundle/theme.xml

Lines changed: 3 additions & 3 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">
@@ -76,7 +76,7 @@
7676
<Checkbox Name="OptionsInstallToolchain" X="192" Y="417" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="0">#(loc.Toolchain_ProductName)</Checkbox>
7777
<Checkbox Name="OptionsInstallAssertsToolchain" X="210" Y="435" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsIncludeNoAsserts and OptionsInstallNoAssertsToolchain">#(loc.Asserts_Toolchain_ProductName)</Checkbox>
7878
<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-
79+
<Checkbox Name="OptionsInstallEmbeddedPython" X="192" Y="471" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallDBG">#(loc.EmbeddedPython_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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2+
<?define VariantName = asserts ?>
3+
<?define VariantUpgradeCode = $(PythonUpgradeCode)?>
4+
<?define VariantProductName = !(loc.EmbeddedPython_ProductName)?>
5+
<?define VariantCabinetName = python.asserts.cab?>
6+
<?define ToolchainVersionedVariantDirectory = ToolchainVersionedAsserts ?>
7+
<?define VariantEnvironmentComponentGUID = 30629e0c-b376-47bc-bedf-fefb7d4ca61d?>
8+
<?define PythonRoot = "$(ImageRoot)\Python-$(PythonVersion)"?>
9+
<?if $(ProductArchitecture) = "arm64" ?>
10+
<?define ArchSuffix = "-arm64" ?>
11+
<?else?>
12+
<?define ArchSuffix = "" ?>
13+
<?endif?>
14+
<?include ../python.wxi ?>
15+
</Wix>
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
3+
4+
<Package
5+
Language="1033"
6+
Manufacturer="!(loc.ManufacturerName)"
7+
Name="$(VariantProductName)"
8+
UpgradeCode="$(VariantUpgradeCode)"
9+
Version="$(NonSemVerProductVersion)"
10+
Scope="$(PackageScope)">
11+
12+
<Media Id="1" Cabinet="$(VariantCabinetName)" EmbedCab="$(ArePackageCabsEmbedded)" />
13+
14+
<WixVariable Id="SideBySidePackageUpgradeCode" Value="$(VariantUpgradeCode)" />
15+
<FeatureGroupRef Id="SideBySideUpgradeStrategy" />
16+
17+
<ComponentGroup Id="EmbeddedPython" Directory="Python">
18+
<Component >
19+
<File Source="$(PythonRoot)\libcrypto-1_1$(ArchSuffix).dll" />
20+
</Component>
21+
22+
<Component>
23+
<File Source="$(PythonRoot)\libffi-7.dll" />
24+
</Component>
25+
26+
<Component>
27+
<File Source="$(PythonRoot)\libssl-1_1$(ArchSuffix).dll" />
28+
</Component>
29+
30+
<Component>
31+
<File Source="$(PythonRoot)\pyexpat.pyd" />
32+
</Component>
33+
34+
<Component>
35+
<File Source="$(PythonRoot)\python.cat" />
36+
</Component>
37+
38+
<Component>
39+
<File Source="$(PythonRoot)\python.exe" />
40+
</Component>
41+
42+
<Component>
43+
<File Source="$(PythonRoot)\python3.dll" />
44+
</Component>
45+
46+
<Component>
47+
<File Source="$(PythonRoot)\python310.dll" />
48+
</Component>
49+
50+
<Component>
51+
<File Source="$(PythonRoot)\python310.zip" />
52+
</Component>
53+
54+
<Component>
55+
<File Source="$(PythonRoot)\python310._pth" />
56+
</Component>
57+
58+
<Component>
59+
<File Source="$(PythonRoot)\pythonw.exe" />
60+
</Component>
61+
62+
<Component>
63+
<File Source="$(PythonRoot)\select.pyd" />
64+
</Component>
65+
66+
<Component>
67+
<File Source="$(PythonRoot)\sqlite3.dll" />
68+
</Component>
69+
70+
<Component>
71+
<File Source="$(PythonRoot)\unicodedata.pyd" />
72+
</Component>
73+
74+
<Component>
75+
<File Source="$(PythonRoot)\winsound.pyd" />
76+
</Component>
77+
78+
<Component>
79+
<File Source="$(PythonRoot)\_asyncio.pyd" />
80+
</Component>
81+
82+
<Component>
83+
<File Source="$(PythonRoot)\_bz2.pyd" />
84+
</Component>
85+
86+
<Component>
87+
<File Source="$(PythonRoot)\_ctypes.pyd" />
88+
</Component>
89+
90+
<Component>
91+
<File Source="$(PythonRoot)\_decimal.pyd" />
92+
</Component>
93+
94+
<Component>
95+
<File Source="$(PythonRoot)\_elementtree.pyd" />
96+
</Component>
97+
98+
<Component>
99+
<File Source="$(PythonRoot)\_hashlib.pyd" />
100+
</Component>
101+
102+
<Component>
103+
<File Source="$(PythonRoot)\_lzma.pyd" />
104+
</Component>
105+
106+
<Component>
107+
<File Source="$(PythonRoot)\_msi.pyd" />
108+
</Component>
109+
110+
<Component>
111+
<File Source="$(PythonRoot)\_multiprocessing.pyd" />
112+
</Component>
113+
114+
<Component>
115+
<File Source="$(PythonRoot)\_overlapped.pyd" />
116+
</Component>
117+
118+
<Component>
119+
<File Source="$(PythonRoot)\_queue.pyd" />
120+
</Component>
121+
122+
<Component>
123+
<File Source="$(PythonRoot)\_socket.pyd" />
124+
</Component>
125+
126+
<Component>
127+
<File Source="$(PythonRoot)\_sqlite3.pyd" />
128+
</Component>
129+
130+
<Component>
131+
<File Source="$(PythonRoot)\_ssl.pyd" />
132+
</Component>
133+
134+
<Component>
135+
<File Source="$(PythonRoot)\_uuid.pyd" />
136+
</Component>
137+
138+
<Component>
139+
<File Source="$(PythonRoot)\_zoneinfo.pyd" />
140+
</Component>
141+
</ComponentGroup>
142+
143+
<ComponentGroup Id="EmbeddedPythonLicense">
144+
<Component Directory="toolchain_$(VariantName)_usr_share_licenses">
145+
<File Source="$(PythonRoot)\LICENSE.txt" />
146+
</Component>
147+
</ComponentGroup>
148+
149+
<Feature Id="EmbeddedPython" AllowAbsent="no" Title="$(VariantProductName)">
150+
<ComponentGroupRef Id="EmbeddedPython" />
151+
<ComponentGroupRef Id="EmbeddedPythonLicense" />
152+
</Feature>
153+
</Package>
154+
</Include>

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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
</DirectoryRef>
3636
</Fragment>
3737

38+
<Fragment>
39+
<DirectoryRef Id="INSTALLROOT">
40+
<Directory Id="Python" Name="Python-$(PythonVersion)" />
41+
</DirectoryRef>
42+
</Fragment>
43+
3844
<Fragment>
3945
<DirectoryRef Id="INSTALLROOT">
4046
<Directory Name="Toolchains">
@@ -55,6 +61,7 @@
5561
<Directory Id="toolchain_asserts_usr_share_docc" Name="docc">
5662
<Directory Id="toolchain_asserts_usr_share_docc_render" Name="render" />
5763
</Directory>
64+
<Directory Id="toolchain_asserts_usr_share_licenses" Name="licenses" />
5865
</Directory>
5966
</Directory>
6067
</Directory>

0 commit comments

Comments
 (0)