Skip to content

Commit

Permalink
[WIP] Update installer to add optional freethreaded install
Browse files Browse the repository at this point in the history
  • Loading branch information
zooba committed Dec 15, 2023
1 parent e6211cb commit 3a7425b
Show file tree
Hide file tree
Showing 20 changed files with 412 additions and 59 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,10 @@ PCbuild/*-pgo
PCbuild/*.VC.db
PCbuild/*.VC.opendb
PCbuild/amd64/
PCbuild/amd64t/
PCbuild/arm32/
PCbuild/arm32t/
PCbuild/arm64/
PCbuild/arm64t/
PCbuild/obj/
PCbuild/win32/
PCbuild/win32t/
Tools/unicode/data/
/autom4te.cache
/build/
Expand Down
4 changes: 4 additions & 0 deletions Lib/venv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,12 @@ def symlink_or_copy(self, src, dst, relative_symlinks_ok=False):
basename = basename[:-2]
if basename.startswith('python'):
basename = 'venvlauncher'
if sysconfig.get_config_var('Py_GIL_DISABLED'):
basename += 't'
elif basename.startswith('pythonw'):
basename = 'venvwlauncher'
if sysconfig.get_config_var('Py_GIL_DISABLED'):
basename += 't'
src = os.path.join(os.path.dirname(src), basename + ext)
else:
src = srcfn
Expand Down
2 changes: 1 addition & 1 deletion PCbuild/pyproject.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<LinkIncremental Condition="$(Configuration) != 'Debug'">false</LinkIncremental>
</PropertyGroup>

<PropertyGroup>
<PropertyGroup Condition="$(TargetExt) != ''">
<TargetNameExt>$(TargetName)$(TargetExt)</TargetNameExt>
<_TargetNameSep>$(TargetNameExt.LastIndexOf(`.`))</_TargetNameSep>
<TargetName>$(TargetNameExt.Substring(0, $(_TargetNameSep)))</TargetName>
Expand Down
52 changes: 16 additions & 36 deletions PCbuild/python.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
<!-- Root directory of the repository -->
<PySourcePath Condition="'$(PySourcePath)' == ''">$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\))</PySourcePath>
<PySourcePath Condition="!HasTrailingSlash($(PySourcePath))">$(PySourcePath)\</PySourcePath>
</PropertyGroup>

<PropertyGroup Condition="$(DisableGil) != 'true'">
<!-- Directory where build outputs are put -->
<BuildPath32 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\win32\</BuildPath32>
<BuildPath32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\win32\</BuildPath32>
Expand All @@ -60,29 +58,6 @@
<PyVPath Condition="$(Configuration) == 'PGInstrument'">..\\..\\..</PyVPath>
</PropertyGroup>

<PropertyGroup Condition="$(DisableGil) == 'true'">
<!-- Directory where build outputs are put -->
<BuildPath32 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\win32t\</BuildPath32>
<BuildPath32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\win32t\</BuildPath32>
<BuildPath64 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\amd64t\</BuildPath64>
<BuildPath64 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\amd64t\</BuildPath64>
<BuildPathArm32 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\arm32t\</BuildPathArm32>
<BuildPathArm32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm32t\</BuildPathArm32>
<BuildPathArm64 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\arm64t\</BuildPathArm64>
<BuildPathArm64 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm64t\</BuildPathArm64>
<BuildPath Condition="'$(ArchName)' == 'win32'">$(BuildPath32)</BuildPath>
<BuildPath Condition="'$(ArchName)' == 'amd64'">$(BuildPath64)</BuildPath>
<BuildPath Condition="'$(ArchName)' == 'arm32'">$(BuildPathArm32)</BuildPath>
<BuildPath Condition="'$(ArchName)' == 'arm64'">$(BuildPathArm64)</BuildPath>
<BuildPath Condition="'$(BuildPath)' == ''">$(PySourcePath)PCbuild\$(ArchName)t\</BuildPath>
<BuildPath Condition="!HasTrailingSlash($(BuildPath))">$(BuildPath)\</BuildPath>
<BuildPath Condition="$(Configuration) == 'PGInstrument'">$(BuildPath)instrumented\</BuildPath>

<!-- VPATH definition (escaped) -->
<PyVPath Condition="$(Configuration) != 'PGInstrument'">..\\..</PyVPath>
<PyVPath Condition="$(Configuration) == 'PGInstrument'">..\\..\\..</PyVPath>
</PropertyGroup>

<!-- Directories of external projects. tcltk is handled in tcltk.props -->
<PropertyGroup>
<ExternalsDir Condition="$(ExternalsDir) == ''">$(EXTERNALS_DIR)</ExternalsDir>
Expand Down Expand Up @@ -259,34 +234,39 @@
<!-- The name of the resulting pythonX.dll (without the extension) -->
<Py3DllName Condition="$(DisableGil) == 'true'">python3t</Py3DllName>
<Py3DllName Condition="$(Py3DllName) == ''">python3</Py3DllName>
</PropertyGroup>

<PropertyGroup Condition="$(DisableGil) != 'true'">
<!-- The version and platform tag to include in .pyd filenames -->
<PydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
<PydTag Condition="$(ArchName) == 'arm32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_arm32</PydTag>
<PydTag Condition="$(ArchName) == 'arm64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_arm64</PydTag>
<PydTag Condition="$(ArchName) == 'amd64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>

<!-- The extension to use for standard library PYDs -->
<PyStdlibPydExt>.pyd</PyStdlibPydExt>

<!-- The version number for sys.winver -->
<SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)$(PyArchExt)$(PyTestExt)</SysWinVer>

<!-- The version and platform tag to include in .pyd filenames for freethreaded builds -->
<FreethreadedPydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win32</FreethreadedPydTag>
<FreethreadedPydTag Condition="$(ArchName) == 'arm32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win_arm32</FreethreadedPydTag>
<FreethreadedPydTag Condition="$(ArchName) == 'arm64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win_arm64</FreethreadedPydTag>
<FreethreadedPydTag Condition="$(ArchName) == 'amd64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win_amd64</FreethreadedPydTag>

<!-- The version number for sys.winver for freethreaded builds -->
<FreethreadedSysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)t$(PyArchExt)$(PyTestExt)</FreethreadedSysWinVer>
</PropertyGroup>

<PropertyGroup Condition="$(DisableGil) != 'true'">
<!-- The extension to use for standard library PYDs -->
<PyStdlibPydExt>.pyd</PyStdlibPydExt>
</PropertyGroup>

<PropertyGroup Condition="$(DisableGil) == 'true'">
<!-- The version and platform tag to include in .pyd filenames -->
<PydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win32</PydTag>
<PydTag Condition="$(ArchName) == 'arm32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win_arm32</PydTag>
<PydTag Condition="$(ArchName) == 'arm64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win_arm64</PydTag>
<PydTag Condition="$(ArchName) == 'amd64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)t-win_amd64</PydTag>
<PydTag>$(FreethreadedPydTag)</PydTag>

<!-- The extension to use for standard library PYDs -->
<PyStdlibPydExt>$(PydTag).pyd</PyStdlibPydExt>

<!-- The version number for sys.winver -->
<SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)t$(PyArchExt)$(PyTestExt)</SysWinVer>
<SysWinVer>$(FreethreadedSysWinVer)</SysWinVer>
</PropertyGroup>

<!-- Displays the calculated version info -->
Expand Down
7 changes: 3 additions & 4 deletions PCbuild/rt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ set qmode=
set dashO=
set regrtestargs=--fast-ci
set exe=
set prefixtail=

:CheckOpts
if "%1"=="-O" (set dashO=-O) & shift & goto CheckOpts
if "%1"=="-q" (set qmode=yes) & shift & goto CheckOpts
if "%1"=="-d" (set suffix=_d) & shift & goto CheckOpts
rem HACK: Need some way to infer the version number in this script
if "%1"=="--disable-gil" (set pyname=python3.13t) & (set prefixtail=t) & shift & goto CheckOpts
if "%1"=="--disable-gil" (set pyname=python3.13t) & shift & goto CheckOpts
if "%1"=="-win32" (set prefix=%pcbuild%win32) & shift & goto CheckOpts
if "%1"=="-x64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts
if "%1"=="-amd64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts
Expand All @@ -53,15 +52,15 @@ if "%1"=="-p" (call :SetPlatform %~2) & shift & shift & goto CheckOpts
if NOT "%1"=="" (set regrtestargs=%regrtestargs% %1) & shift & goto CheckOpts

if not defined prefix set prefix=%pcbuild%amd64
set exe=%prefix%%prefixtail%\%pyname%%suffix%.exe
set exe=%prefix%\%pyname%%suffix%.exe
set cmd="%exe%" %dashO% -m test %regrtestargs%
if defined qmode goto Qmode

echo Deleting .pyc files ...
"%exe%" "%pcbuild%rmpyc.py"

echo Cleaning _pth files ...
if exist %prefix%%prefixtail%\*._pth del %prefix%%prefixtail%\*._pth
if exist %prefix%\*._pth del %prefix%\*._pth

echo on
%cmd%
Expand Down
3 changes: 2 additions & 1 deletion PCbuild/venvlauncher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{494BAC80-A60C-43A9-99E7-ACB691CE2C4D}</ProjectGuid>
<RootNamespace>venvlauncher</RootNamespace>
<TargetName>venvlauncher</TargetName>
<SupportPGO>false</SupportPGO>
</PropertyGroup>
<Import Project="python.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<TargetName>venvlauncher</TargetName>
<TargetName Condition="$(DisableGil) == 'true'">$(TargetName)t</TargetName>
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion PCbuild/venvwlauncher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{FDB84CBB-2FB6-47C8-A2D6-091E0833239D}</ProjectGuid>
<RootNamespace>venvwlauncher</RootNamespace>
<TargetName>venvwlauncher</TargetName>
<SupportPGO>false</SupportPGO>
</PropertyGroup>
<Import Project="python.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<TargetName>venvwlauncher</TargetName>
<TargetName Condition="$(DisableGil) == 'true'">$(TargetName)t</TargetName>
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions Tools/msi/bundle/bundle.targets
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<Package Include="..\tcltk\tcltk*.wixproj" />
<Package Include="..\test\test*.wixproj" />
<Package Include="..\ucrt\ucrt*.wixproj" Condition="$(Platform) != 'ARM64'" />
<Package Include="..\freethreaded\freethreaded*.wixproj" Condition="$(IncludeFreethreaded) == 'true'" />
</ItemGroup>

<PropertyGroup>
Expand Down
4 changes: 4 additions & 0 deletions Tools/msi/bundle/bundle.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<?endif ?>
<Variable Name="Include_symbols" Value="0" bal:Overridable="yes" />
<Variable Name="Include_debug" Value="0" bal:Overridable="yes" />
<Variable Name="Include_freethreaded" Value="0" bal:Overridable="yes" />

<Variable Name="LauncherOnly" Value="0" bal:Overridable="yes" />
<Variable Name="DetectedLauncher" Value="0" />
Expand All @@ -104,6 +105,9 @@
<PackageGroupRef Id="exe" />
<PackageGroupRef Id="dev" />
<PackageGroupRef Id="lib" />
<?if $(var.IncludeFreethreaded)~="true" ?>
<PackageGroupRef Id="freethreaded" />
<?endif ?>
<PackageGroupRef Id="test" />
<PackageGroupRef Id="doc" />
<PackageGroupRef Id="tcltk" />
Expand Down
62 changes: 62 additions & 0 deletions Tools/msi/bundle/packagegroups/freethreaded.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<PackageGroup Id="freethreaded">
<MsiPackage Id="freethreaded_AllUsers"
SourceFile="freethreaded.msi"
Compressed="no"
DownloadUrl="$(var.DownloadUrl)"
ForcePerMachine="yes"
InstallCondition="InstallAllUsers and (Include_freethreaded) and not LauncherOnly">
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
</MsiPackage>
<MsiPackage Id="freethreaded_AllUsers_pdb"
SourceFile="freethreaded_pdb.msi"
Compressed="no"
DownloadUrl="$(var.DownloadUrl)"
ForcePerMachine="yes"
InstallCondition="InstallAllUsers and (Include_freethreaded) and Include_symbols and not LauncherOnly">
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
</MsiPackage>
<MsiPackage Id="freethreaded_AllUsers_d"
SourceFile="freethreaded_d.msi"
Compressed="no"
DownloadUrl="$(var.DownloadUrl)"
ForcePerMachine="yes"
InstallCondition="InstallAllUsers and (Include_freethreaded) and Include_debug and not LauncherOnly">
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
</MsiPackage>

<MsiPackage Id="freethreaded_JustForMe"
SourceFile="freethreaded.msi"
Compressed="no"
DownloadUrl="$(var.DownloadUrl)"
ForcePerMachine="no"
InstallCondition="not InstallAllUsers and (Include_freethreaded) and not LauncherOnly">
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
</MsiPackage>
<MsiPackage Id="freethreaded_JustForMe_pdb"
SourceFile="freethreaded_pdb.msi"
Compressed="no"
DownloadUrl="$(var.DownloadUrl)"
ForcePerMachine="no"
InstallCondition="not InstallAllUsers and (Include_freethreaded) and Include_symbols and not LauncherOnly">
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
</MsiPackage>
<MsiPackage Id="freethreaded_JustForMe_d"
SourceFile="freethreaded_d.msi"
Compressed="no"
DownloadUrl="$(var.DownloadUrl)"
ForcePerMachine="no"
InstallCondition="not InstallAllUsers and (Include_freethreaded) and Include_debug and not LauncherOnly">
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
</MsiPackage>
</PackageGroup>
</Fragment>
</Wix>
20 changes: 20 additions & 0 deletions Tools/msi/freethreaded/freethreaded.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{1B4502D5-B627-4F50-ABEA-4CC5A8E88265}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>freethreaded</OutputName>
<OutputType>Package</OutputType>
</PropertyGroup>
<Import Project="..\msi.props" />
<ItemGroup>
<Compile Include="freethreaded.wxs" />
<Compile Include="freethreaded_files.wxs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="*.wxl" />
<WxlTemplate Include="*.wxl_template" />
</ItemGroup>

<Import Project="..\msi.targets" />
</Project>
18 changes: 18 additions & 0 deletions Tools/msi/freethreaded/freethreaded.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Language="!(loc.LCID)" Name="!(loc.Title)" Version="$(var.Version)" Manufacturer="!(loc.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
<Package InstallerVersion="500" Compressed="yes" InstallScope="perUser" />
<MediaTemplate EmbedCab="yes" CompressionLevel="high" />

<PropertyRef Id="UpgradeTable" />
<PropertyRef Id="REGISTRYKEY" />

<Feature Id="DefaultFeature" AllowAdvertise="no" Title="!(loc.Title)" Description="!(loc.Description)">
<ComponentGroupRef Id="freethreaded_reg" Primary="yes" />
<ComponentGroupRef Id="freethreaded_exe" />
<ComponentGroupRef Id="freethreaded_lib_files" />
<ComponentGroupRef Id="freethreaded_lib_extensions" />
<ComponentRef Id="OptionalFeature" />
</Feature>
</Product>
</Wix>
20 changes: 20 additions & 0 deletions Tools/msi/freethreaded/freethreaded_d.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{D3677DCF-098A-4398-9FA5-8E74AC37E0DF}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>freethreaded_d</OutputName>
<OutputType>Package</OutputType>
</PropertyGroup>
<Import Project="..\msi.props" />
<ItemGroup>
<Compile Include="freethreaded_d.wxs" />
<Compile Include="freethreaded_files.wxs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="*.wxl" />
<WxlTemplate Include="*.wxl_template" />
</ItemGroup>

<Import Project="..\msi.targets" />
</Project>
16 changes: 16 additions & 0 deletions Tools/msi/freethreaded/freethreaded_d.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Language="!(loc.LCID)" Name="!(loc.Title_d)" Version="$(var.Version)" Manufacturer="!(loc.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
<Package InstallerVersion="500" Compressed="yes" InstallScope="perUser" />
<MediaTemplate EmbedCab="yes" CompressionLevel="high" />

<PropertyRef Id="UpgradeTable" />

<Feature Id="DebugBinaries" AllowAdvertise="no" Title="!(loc.Title_d)" Description="!(loc.Description_d)">
<ComponentGroupRef Id="freethreaded_dll_d" />
<ComponentGroupRef Id="freethreaded_exe_d" />
<ComponentGroupRef Id="freethreaded_lib_extensions_d" />
<ComponentRef Id="OptionalFeature" />
</Feature>
</Product>
</Wix>
8 changes: 8 additions & 0 deletions Tools/msi/freethreaded/freethreaded_en-US.wxl_template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
<String Id="Descriptor">Freethreaded Interpreter</String>
<String Id="ShortDescriptor">freethreaded</String>
<String Id="ShortcutName">Python {{ShortVersion}} ({{Bitness}}, freethreaded)</String>
<String Id="ShortcutDescription">Launches the !(loc.ProductName) freethreaded interpreter.</String>
<String Id="SupportUrl">https://www.python.org/</String>
</WixLocalization>
Loading

0 comments on commit 3a7425b

Please sign in to comment.