Skip to content

Commit 497fa7e

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

File tree

11 files changed

+171
-5
lines changed

11 files changed

+171
-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\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: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
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="$(VariantProductName)"
13+
UpgradeCode="$(VariantUpgradeCode)"
14+
Version="$(NonSemVerProductVersion)"
15+
Scope="$(PackageScope)">
16+
17+
<Media Id="1" Cabinet="$(VariantCabinetName)" EmbedCab="$(ArePackageCabsEmbedded)" />
18+
19+
<WixVariable Id="SideBySidePackageUpgradeCode" Value="$(VariantUpgradeCode)" />
20+
<FeatureGroupRef Id="SideBySideUpgradeStrategy" />
21+
22+
<ComponentGroup Id="EmbeddedPython" Directory="Python">
23+
<Component>
24+
<File Source="$(PythonRoot)\libcrypto-1_1$(ArchSuffix).dll" />
25+
</Component>
26+
<Component>
27+
<File Source="$(PythonRoot)\libffi-7.dll" />
28+
</Component>
29+
30+
<Component>
31+
<File Source="$(PythonRoot)\libssl-1_1$(ArchSuffix).dll" />
32+
</Component>
33+
<Component>
34+
<File Source="$(PythonRoot)\pyexpat.pyd" />
35+
</Component>
36+
<Component>
37+
<File Source="$(PythonRoot)\python.cat" />
38+
</Component>
39+
<Component>
40+
<File Source="$(PythonRoot)\python.exe" />
41+
</Component>
42+
<Component>
43+
<File Source="$(PythonRoot)\python3.dll" />
44+
</Component>
45+
<Component>
46+
<File Source="$(PythonRoot)\python310.dll" />
47+
</Component>
48+
<Component>
49+
<File Source="$(PythonRoot)\python310.zip" />
50+
</Component>
51+
<Component>
52+
<File Source="$(PythonRoot)\python310._pth" />
53+
</Component>
54+
<Component>
55+
<File Source="$(PythonRoot)\pythonw.exe" />
56+
</Component>
57+
<Component>
58+
<File Source="$(PythonRoot)\select.pyd" />
59+
</Component>
60+
<Component>
61+
<File Source="$(PythonRoot)\sqlite3.dll" />
62+
</Component>
63+
<Component>
64+
<File Source="$(PythonRoot)\unicodedata.pyd" />
65+
</Component>
66+
<Component>
67+
<File Source="$(PythonRoot)\winsound.pyd" />
68+
</Component>
69+
<Component>
70+
<File Source="$(PythonRoot)\_asyncio.pyd" />
71+
</Component>
72+
<Component>
73+
<File Source="$(PythonRoot)\_bz2.pyd" />
74+
</Component>
75+
<Component>
76+
<File Source="$(PythonRoot)\_ctypes.pyd" />
77+
</Component>
78+
<Component>
79+
<File Source="$(PythonRoot)\_decimal.pyd" />
80+
</Component>
81+
<Component>
82+
<File Source="$(PythonRoot)\_elementtree.pyd" />
83+
</Component>
84+
<Component>
85+
<File Source="$(PythonRoot)\_hashlib.pyd" />
86+
</Component>
87+
<Component>
88+
<File Source="$(PythonRoot)\_lzma.pyd" />
89+
</Component>
90+
<Component>
91+
<File Source="$(PythonRoot)\_msi.pyd" />
92+
</Component>
93+
<Component>
94+
<File Source="$(PythonRoot)\_multiprocessing.pyd" />
95+
</Component>
96+
<Component>
97+
<File Source="$(PythonRoot)\_overlapped.pyd" />
98+
</Component>
99+
<Component>
100+
<File Source="$(PythonRoot)\_queue.pyd" />
101+
</Component>
102+
<Component>
103+
<File Source="$(PythonRoot)\_socket.pyd" />
104+
</Component>
105+
<Component>
106+
<File Source="$(PythonRoot)\_sqlite3.pyd" />
107+
</Component>
108+
<Component>
109+
<File Source="$(PythonRoot)\_ssl.pyd" />
110+
</Component>
111+
<Component>
112+
<File Source="$(PythonRoot)\_uuid.pyd" />
113+
</Component>
114+
<Component>
115+
<File Source="$(PythonRoot)\_zoneinfo.pyd" />
116+
</Component>
117+
</ComponentGroup>
118+
119+
<ComponentGroup Id="EmbeddedPythonLicense">
120+
<Component Directory="python_licenses">
121+
<File Source="$(PythonRoot)\LICENSE.txt" />
122+
</Component>
123+
</ComponentGroup>
124+
125+
<Feature Id="EmbeddedPython" AllowAbsent="no" Title="$(VariantProductName)">
126+
<ComponentGroupRef Id="EmbeddedPython" />
127+
<ComponentGroupRef Id="EmbeddedPythonLicense" />
128+
</Feature>
129+
</Package>
130+
</Include>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2+
<?define VariantUpgradeCode = $(PythonUpgradeCode)?>
3+
<?define VariantProductName = !(loc.EmbeddedPython_ProductName)?>
4+
<?define VariantCabinetName = python.cab?>
5+
<?define VariantEnvironmentComponentGUID = 30629e0c-b376-47bc-bedf-fefb7d4ca61d?>
6+
<?define PythonRoot = "$(ImageRoot)\Python-$(PythonVersion)"?>
7+
<?include ./python.wxi ?>
8+
</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">

0 commit comments

Comments
 (0)