Skip to content

[windows] add Python 3.10.1 to the installer #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platforms/Windows/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
ArePackageCabsEmbedded=$(ArePackageCabsEmbedded);
BaseReleaseDownloadUrl=$(BaseReleaseDownloadUrl);
ImageRoot=$(ImageRoot);
PythonRoot=$(PythonRoot);
WindowsRuntimeARM64=$(WindowsRuntimeARM64);
WindowsRuntimeX64=$(WindowsRuntimeX64);
WindowsRuntimeX86=$(WindowsRuntimeX86);
Expand Down
2 changes: 2 additions & 0 deletions platforms/Windows/SideBySideUpgradeStrategy.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<RtlUpgradeCode>{BEA8C6DC-F73E-445B-9486-2333D1CF2886}</RtlUpgradeCode>
<AndroidPlatformUpgradeCode>{313B9C1F-D5B5-4FED-B7E0-138F1EE6B26A}</AndroidPlatformUpgradeCode>
<WindowsPlatformUpgradeCode>{01AFF1CF-A025-41B6-BCBC-728D794353FD}</WindowsPlatformUpgradeCode>
<PythonUpgradeCode>{5FC42BA9-ABF5-4CCD-B93B-BDFED936BA37}</PythonUpgradeCode>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name should have variant to allow us to add another one later on. PythonAssertsUpgradeCode

</PropertyGroup>

<PropertyGroup Condition="'$(MajorMinorProductVersion)' == '0.0'">
Expand Down Expand Up @@ -61,6 +62,7 @@
RtlUpgradeCode=$(RtlUpgradeCode);
AndroidPlatformUpgradeCode=$(AndroidPlatformUpgradeCode);
WindowsPlatformUpgradeCode=$(WindowsPlatformUpgradeCode);
PythonUpgradeCode=$(PythonUpgradeCode);
</DefineConstants>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions platforms/Windows/bundle/installer.wixproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<ProjectReference Include="..\cli\asserts\cli.asserts.wixproj" BindName="cli.asserts" />
<ProjectReference Include="..\dbg\asserts\dbg.asserts.wixproj" BindName="dbg.asserts" />
<ProjectReference Include="..\ide\asserts\ide.asserts.wixproj" BindName="ide.asserts" />
<ProjectReference Include="..\python\asserts\python.wixproj" BindName="python" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<ProjectReference Include="..\python\asserts\python.wixproj" BindName="python" />
<ProjectReference Include="..\python\asserts\python.asserts.wixproj" BindName="python.asserts" />

<ProjectReference Include="..\rtl\msi\rtlmsi.wixproj" BindName="rtl" />
</ItemGroup>

Expand Down
7 changes: 7 additions & 0 deletions platforms/Windows/bundle/installer.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@
<MsiProperty Name="INSTALLROOT" Value="[InstallRoot]" />
</MsiPackage>

<MsiPackage
SourceFile="!(bindpath.python)\python.msi"
InstallCondition="OptionsInstallEmbeddedPython = 1"
DownloadUrl="$(BaseReleaseDownloadUrl)/{2}">
<MsiProperty Name="INSTALLROOT" Value="[InstallRoot]" />
</MsiPackage>

<MsiPackage
SourceFile="!(bindpath.ide.asserts)\ide.asserts.msi"
InstallCondition="OptionsInstallIDE = 1"
Expand Down
2 changes: 1 addition & 1 deletion platforms/Windows/bundle/theme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<Checkbox Name="OptionsInstallAndroidSDKAMD64" X="210" Y="363" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_amd64)</Checkbox>
<Checkbox Name="OptionsInstallAndroidSDKARM" X="210" Y="381" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_armv7)</Checkbox>
<Checkbox Name="OptionsInstallAndroidSDKX86" X="210" Y="399" Width="-11" Height="17" TabStop="yes" FontId="3" EnableCondition="OptionsInstallAndroidPlatform">#(loc.Sdk_ProductName_Android_x86)</Checkbox>

<Checkbox Name="OptionsInstallEmbeddedPython" X="192" Y="417" Width="-11" Height="17" TabStop="yes" FontId="3">#(loc.EmbeddedPython_ProductName)</Checkbox>
<Button Name="OptionsOkButton" X="-91" Y="-11" Width="75" Height="23" TabStop="yes" FontId="0">
<Text>#(loc.OptionsOkButton)</Text>
<ChangePageAction Page="Install" />
Expand Down
5 changes: 5 additions & 0 deletions platforms/Windows/python/asserts/python.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project Sdk="WixToolset.Sdk/4.0.5">
<PropertyGroup>
<OutputName>python</OutputName>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The msi name should have the variant in it to separate it when we build multiple for each variant

Suggested change
<OutputName>python</OutputName>
<OutputName>python.asserts</OutputName>

</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions platforms/Windows/python/asserts/python.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<?define VariantName = asserts ?>
<?define VariantUpgradeCode = $(PythonUpgradeCode)?>
<?define VariantProductName = !(loc.EmbeddedPython_ProductName)?>
<?define VariantCabinetName = python.asserts.cab?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, the cabinet name should not have .asserts in the name. We do not build the python interpreter with assertions.

Copy link
Contributor

@mhegazy mhegazy Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we install the embedded-python binaries to a variant-specific folder. so this means that each variant will need a copy.

the right approach would be to install python to a non-variant-specific folder, e.g. it is own folder. and add it to the path so that lldb would find it. this way we only have one msi. bonus if we change lldb to use an env var or other input to know where the embedded one is instead of using path for the dll and PYTHONPATH for the libraries.

<?define ToolchainVersionedVariantDirectory = ToolchainVersionedAsserts ?>
<?define VariantEnvironmentComponentGUID = 30629e0c-b376-47bc-bedf-fefb7d4ca61d?>
<?if $(ProductArchitecture) = "arm64" ?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not variant specific. i would recommend moving it to the wxi to avoid it being duplicated for diffrent variants.

<?define ArchSuffix = "-arm64" ?>
<?else?>
<?define ArchSuffix = "" ?>
<?endif?>
<?include ../python.wxi ?>
</Wix>
154 changes: 154 additions & 0 deletions platforms/Windows/python/python.wxi
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">

<Package
Language="1033"
Manufacturer="!(loc.ManufacturerName)"
Name="$(VariantProductName)"
UpgradeCode="$(VariantUpgradeCode)"
Version="$(NonSemVerProductVersion)"
Scope="$(PackageScope)">

<Media Id="1" Cabinet="$(VariantCabinetName)" EmbedCab="$(ArePackageCabsEmbedded)" />

<WixVariable Id="SideBySidePackageUpgradeCode" Value="$(VariantUpgradeCode)" />
<FeatureGroupRef Id="SideBySideUpgradeStrategy" />

<ComponentGroup Id="EmbeddedPython" Directory="toolchain_$(VariantName)_usr_bin">
<Component >
<File Source="$(PythonRoot)\libcrypto-1_1$(ArchSuffix).dll" />
</Component>

<Component>
<File Source="$(PythonRoot)\libffi-7.dll" />
</Component>

<Component>
<File Source="$(PythonRoot)\libssl-1_1$(ArchSuffix).dll" />
</Component>

<Component>
<File Source="$(PythonRoot)\pyexpat.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\python.cat" />
</Component>

<Component>
<File Source="$(PythonRoot)\python.exe" />
</Component>

<Component>
<File Source="$(PythonRoot)\python3.dll" />
</Component>

<Component>
<File Source="$(PythonRoot)\python310.dll" />
</Component>

<Component>
<File Source="$(PythonRoot)\python310.zip" />
</Component>

<Component>
<File Source="$(PythonRoot)\python310._pth" />
</Component>

<Component>
<File Source="$(PythonRoot)\pythonw.exe" />
</Component>

<Component>
<File Source="$(PythonRoot)\select.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\sqlite3.dll" />
</Component>

<Component>
<File Source="$(PythonRoot)\unicodedata.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\winsound.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_asyncio.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_bz2.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_ctypes.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_decimal.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_elementtree.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_hashlib.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_lzma.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_msi.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_multiprocessing.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_overlapped.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_queue.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_socket.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_sqlite3.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_ssl.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_uuid.pyd" />
</Component>

<Component>
<File Source="$(PythonRoot)\_zoneinfo.pyd" />
</Component>
</ComponentGroup>

<ComponentGroup Id="EmbeddedPythonLicense">
<Component Directory="toolchain_$(VariantName)_usr_share_licenses">
<File Source="$(PythonRoot)\LICENSE.txt" />
</Component>
</ComponentGroup>

<Feature Id="EmbeddedPython" AllowAbsent="no" Title="$(VariantProductName)">
<ComponentGroupRef Id="EmbeddedPython" />
<ComponentGroupRef Id="EmbeddedPythonLicense" />
</Feature>
</Package>
</Include>
7 changes: 5 additions & 2 deletions platforms/Windows/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The bundle authoring (in `installer.wxs`) drives optional install directory and
| 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. |
| OptionsInstallCLI | Controls whether command-line tools will be installed. |
| OptionsInstallDBG | Controls whether debugging tools will be installed. |
| OptionsInstallEmbeddedPython | Controls whether embeddable Python will be installed. |
| OptionsInstallIDE | Controls whether IDE integration tools will be installed. |
| OptionsInstallUtilties | Controls whether additional utilities will be installed. |
| OptionsInstallAndroidPlatform | Controls whether the Android platform will be installed. |
Expand Down Expand Up @@ -149,6 +150,7 @@ To support the three architecture flavors of the SDK and RTL MSI packages, you n
| MSBuild property | Description |
| ---------------- | ----------- |
| ImageRoot | Path to the root of the installed Swift image to package |
| PythonRoot | Path to the root of the Python distribution to package |
| Platforms | Semicolon delimited list of platforms to package (android;windows) |
| AndroidArchitectures | Semicolon delimited list of architectures the Android platform supports (aarch54;armv7;i686;x86_64) |
| WindowsArchitectures | Semicolon delimited list of architectures the Windows platform supports (aarch64;i686;x86_64) |
Expand All @@ -165,10 +167,11 @@ msbuild %SourceRoot%\swift-installer-scripts\platforms\Windows\bundle\installer.
-p:Configuration=Release ^
-p:BaseOutputPath=%PackageRoot%\online\ ^
-p:ImageRoot=%ImageRoot%\Program Files\Swift ^
-p:PythonRoot=%ImageRoot%\Program Files\Python-3.10.1 ^
-p:Platforms="android;windows" ^
-p:AndroidArchitectures="aarch64;armv7;i686;x86_64" ^
-p:WindowsArchitectures="aarch64;i686;x86_64" ^
-p:WindowsRuntimeARM64=%ImageRoot%\Prograam Files (Arm64)\Swift\Runtimes\0.0.0 ^
-p:WindowsRuntimeARM64=%ImageRoot%\Program Files (Arm64)\Swift\Runtimes\0.0.0 ^
-p:WindowsRuntimeX64=%ImageRoot%\Program Files\Swift\Runtimes\0.0.0 ^
-p:WindowsRuntimeX86=%ImageRoot%\Program Files (x86)\Swift\Runtimes\0.0.0
```
Expand Down Expand Up @@ -216,7 +219,7 @@ Note that these GUIDs are substituted at bind time so they skip the normal valid

| Property | Description |
| -------- | ----------- |
| BldAssertsUpgradeCode, CliAssertsUpgradeCode, DbgAssertsUpgradeCode, IdeUpgradeCode, 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`. |
| BldAssertsUpgradeCode, CliAssertsUpgradeCode, DbgAssertsUpgradeCode, IdeUpgradeCode, 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`. |
| 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. |


Expand Down
1 change: 1 addition & 0 deletions platforms/Windows/shared/shared.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<Directory Id="toolchain_asserts_usr_share_docc" Name="docc">
<Directory Id="toolchain_asserts_usr_share_docc_render" Name="render" />
</Directory>
<Directory Id="toolchain_asserts_usr_share_licenses" Name="licenses" />
</Directory>
</Directory>
</Directory>
Expand Down
1 change: 1 addition & 0 deletions platforms/Windows/shared/swift.en-us.wxl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<String Id="CliAsserts_ProductName" Value="Swift Command Line Tools (Asserts)" />
<String Id="Dbg_ProductName" Value="Swift Debugging Tools" />
<String Id="DbgAsserts_ProductName" Value="Swift Debugging Tools (Asserts)" />
<String Id="EmbeddedPython_ProductName" Value="Embedded Python 3.10.1" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is variant specific msi, we should have the name reflect that.

Suggested change
<String Id="EmbeddedPython_ProductName" Value="Embedded Python 3.10.1" />
<String Id="EmbeddedPythonAsserts_ProductName" Value="Embedded Python 3.10.1 (Asserts)" />

<String Id="Ide_ProductName" Value="Swift IDE Integration Tools" />
<String Id="IdeAsserts_ProductName" Value="Swift IDE Integration Tools (Asserts)" />
<String Id="Rtl_ProductName" Value="Swift Windows Runtime" />
Expand Down