Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 940f6a8

Browse files
committed
Improves handling of test markers for building Python without intefering with actual installs.
1 parent f97edf1 commit 940f6a8

13 files changed

Lines changed: 93 additions & 63 deletions

File tree

PCbuild/build.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ echo. -p x64 ^| Win32
3838
echo. Set the platform (default: Win32)
3939
echo. -t Build ^| Rebuild ^| Clean ^| CleanAll
4040
echo. Set the target manually
41+
echo. --test-marker Enable the test marker within the build.
4142
exit /b 127
4243

4344
:Run
@@ -62,6 +63,7 @@ if "%~1"=="-m" (set parallel=/m) & shift & goto CheckOpts
6263
if "%~1"=="-M" (set parallel=) & shift & goto CheckOpts
6364
if "%~1"=="-v" (set verbose=/v:n) & shift & goto CheckOpts
6465
if "%~1"=="-k" (set kill=true) & shift & goto CheckOpts
66+
if "%~1"=="--test-marker" (set UseTestMarker=true) & shift & goto CheckOpts
6567
if "%~1"=="-V" shift & goto Version
6668
rem These use the actual property names used by MSBuild. We could just let
6769
rem them in through the environment, but we specify them on the command line
@@ -93,6 +95,7 @@ msbuild "%dir%pcbuild.proj" /t:%target% %parallel% %verbose%^
9395
/p:Configuration=%conf% /p:Platform=%platf%^
9496
/p:IncludeExternals=%IncludeExternals%^
9597
/p:IncludeSSL=%IncludeSSL% /p:IncludeTkinter=%IncludeTkinter%^
98+
/p:UseTestMarker=%UseTestMarker%^
9699
%1 %2 %3 %4 %5 %6 %7 %8 %9
97100

98101
@goto :eof

PCbuild/pyproject.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses
128128
</UsingTask>
129129

130130
<Target Name="KillPython" BeforeTargets="PrepareForBuild" Condition="'$(KillPython)' == 'true'">
131-
<Message Text="Killing any running python.exe instances..." Importance="high" />
132-
<KillPython FileName="$(OutDir)python$(PyDebugExt).exe" />
131+
<Message Text="Killing any running python$(PyDebugExt)$(PyTestExt).exe instances..." Importance="high" />
132+
<KillPython FileName="$(OutDir)python$(PyDebugExt)$(PyTestExt).exe" />
133133
</Target>
134134

135135
<!--

PCbuild/python.props

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
<!-- Suffix for all binaries when building for debug -->
4242
<PyDebugExt Condition="'$(PyDebugExt)' == '' and $(Configuration) == 'Debug'">_d</PyDebugExt>
4343

44+
<!-- Suffix for versions/keys when building with test markers -->
45+
<PyTestExt Condition="$(UseTestMarker) == 'true'">-test</PyTestExt>
46+
47+
<!-- Suffix for versions/keys when building for particular platforms -->
48+
<PyArchExt Condition="'$(ArchName)' == 'win32'">-32</PyArchExt>
49+
4450
<!-- Full path of the resulting python.exe binary -->
4551
<PythonExe Condition="'$(PythonExe)' == ''">$(BuildPath)python$(PyDebugExt).exe</PythonExe>
4652
</PropertyGroup>
@@ -129,17 +135,17 @@
129135
$([msbuild]::Multiply($(MicroVersionNumber), 1000))
130136
))
131137
))</Field3Value>
138+
<Field3Value Condition="$(UseTestMarker) == 'true'">$([msbuild]::Add($(Field3Value), 9000))</Field3Value>
132139

133140
<!-- The name of the resulting pythonXY.dll (without the extension) -->
134141
<PyDllName>python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt)</PyDllName>
135142

136143
<!-- The version and platform tag to include in .pyd filenames -->
137-
<PydTag Condition="$(Platform) == 'Win32' or $(Platform) == 'x86'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
138-
<PydTag Condition="$(Platform) == 'x64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
144+
<PydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
145+
<PydTag Condition="$(ArchName) == 'amd64'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_amd64</PydTag>
139146

140147
<!-- The version number for sys.winver -->
141-
<SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)</SysWinVer>
142-
<SysWinVer Condition="$(Platform) == 'Win32' or $(Platform) == 'x86'">$(SysWinVer)-32</SysWinVer>
148+
<SysWinVer>$(MajorVersionNumber).$(MinorVersionNumber)$(PyArchExt)$(PyTestExt)</SysWinVer>
143149
</PropertyGroup>
144150

145151
<!-- Displays the calculated version info -->
@@ -148,5 +154,7 @@
148154
<Message Importance="high" Text="PythonVersion: $(PythonVersion)" />
149155
<Message Importance="high" Text="PythonVersionHex: 0x$([System.UInt32]::Parse($(PythonVersionHex)).ToString(`X08`))" />
150156
<Message Importance="high" Text="Field3Value: $(Field3Value)" />
157+
<Message Importance="high" Text="SysWinVer: $(SysWinVer)" />
158+
<Message Importance="high" Text="PyDllName: $(PyDllName)" />
151159
</Target>
152160
</Project>

Tools/msi/build.bat

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ set PCBUILD=%D%..\..\PCBuild\
66
set BUILDX86=
77
set BUILDX64=
88
set BUILDDOC=
9-
set BUILDPX=
9+
set BUILDTEST=--test-marker
1010
set BUILDPACK=
11+
set REBUILD=
1112

1213
:CheckOpts
1314
if "%~1" EQU "-h" goto Help
1415
if "%~1" EQU "-x86" (set BUILDX86=1) && shift && goto CheckOpts
1516
if "%~1" EQU "-x64" (set BUILDX64=1) && shift && goto CheckOpts
1617
if "%~1" EQU "--doc" (set BUILDDOC=1) && shift && goto CheckOpts
17-
if "%~1" EQU "--test-marker" (set BUILDPX=1) && shift && goto CheckOpts
18+
if "%~1" EQU "--no-test-marker" (set BUILDTEST=) && shift && goto CheckOpts
1819
if "%~1" EQU "--pack" (set BUILDPACK=1) && shift && goto CheckOpts
20+
if "%~1" EQU "-r" (set REBUILD=-r) && shift && goto CheckOpts
1921

2022
if not defined BUILDX86 if not defined BUILDX64 (set BUILDX86=1) && (set BUILDX64=1)
2123

@@ -24,15 +26,15 @@ call "%D%get_externals.bat"
2426
call "%PCBUILD%env.bat" x86
2527

2628
if defined BUILDX86 (
27-
call "%PCBUILD%build.bat" -d -e
29+
call "%PCBUILD%build.bat" -d -e %REBUILD% %BUILDTEST%
2830
if errorlevel 1 goto :eof
29-
call "%PCBUILD%build.bat" -e
31+
call "%PCBUILD%build.bat" -e %REBUILD% %BUILDTEST%
3032
if errorlevel 1 goto :eof
3133
)
3234
if defined BUILDX64 (
33-
call "%PCBUILD%build.bat" -p x64 -d -e
35+
call "%PCBUILD%build.bat" -p x64 -d -e %REBUILD% %BUILDTEST%
3436
if errorlevel 1 goto :eof
35-
call "%PCBUILD%build.bat" -p x64 -e
37+
call "%PCBUILD%build.bat" -p x64 -e %REBUILD% %BUILDTEST%
3638
if errorlevel 1 goto :eof
3739
)
3840

@@ -42,12 +44,15 @@ if defined BUILDDOC (
4244
)
4345

4446
set BUILD_CMD="%D%bundle\snapshot.wixproj"
45-
if defined BUILDPX (
47+
if defined BUILDTEST (
4648
set BUILD_CMD=%BUILD_CMD% /p:UseTestMarker=true
4749
)
4850
if defined BUILDPACK (
4951
set BUILD_CMD=%BUILD_CMD% /p:Pack=true
5052
)
53+
if defined REBUILD (
54+
set BUILD_CMD=%BUILD_CMD% /t:Rebuild
55+
)
5156

5257
if defined BUILDX86 (
5358
msbuild %BUILD_CMD%
@@ -61,10 +66,11 @@ if defined BUILDX64 (
6166
exit /B 0
6267

6368
:Help
64-
echo build.bat [-x86] [-x64] [--doc] [-h] [--test-marker] [--pack]
69+
echo build.bat [-x86] [-x64] [--doc] [-h] [--no-test-marker] [--pack] [-r]
6570
echo.
6671
echo -x86 Build x86 installers
6772
echo -x64 Build x64 installers
6873
echo --doc Build CHM documentation
69-
echo --test-marker Build installers with 'x' markers
74+
echo --no-test-marker Build without test markers
7075
echo --pack Embed core MSIs into installer
76+
echo -r Rebuild rather than incremental build

Tools/msi/bundle/Default.thm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<Checkbox Name="Include_test" X="185" Y="201" Width="-11" Height="24" TabStop="yes" FontId="3" HideWhenDisabled="yes">#(loc.Include_testLabel)</Checkbox>
6565
<Text X="205" Y="226" Width="-11" Height="24" TabStop="no" FontId="5">#(loc.Include_testHelpLabel)</Text>
6666

67-
<Checkbox Name="Include_launcher" X="185" Y="251" Width="100" Height="24" TabStop="yes" FontId="3" HideWhenDisabled="yes">#(loc.Include_launcherLabel)</Checkbox>
67+
<Checkbox Name="Include_launcher" X="185" Y="251" Width="100" Height="24" TabStop="yes" FontId="3" HideWhenDisabled="no">#(loc.Include_launcherLabel)</Checkbox>
6868
<Checkbox Name="CustomInstallLauncherAllUsers" X="285" Y="251" Width="-11" Height="24" TabStop="yes" FontId="3">#(loc.InstallLauncherAllUsersLabel)</Checkbox>
6969
<Text X="205" Y="276" Width="-11" Height="24" TabStop="no" FontId="5">#(loc.Include_launcherHelpLabel)</Text>
7070

Tools/msi/bundle/bundle.targets

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@
8888
</Target>
8989

9090
<Target Name="BuildLauncher" BeforeTargets="BeforeBuild" Condition="'$(RebuildAll)' != 'false'">
91-
<!-- Build the launcher MSI using Exec rather than MSBuild -->
92-
<Exec Command='msbuild ..\launcher\launcher.wixproj /p:Platform=x86 /p:ReleaseUri="$(ReleaseUri)" /p:OutputPath="$(BuildPath.TrimEnd(`\`))" /p:OutputSuffix=$(Platform) /p:BuildForRelease=$(BuildForRelease) /p:UseTestMarker=$(UseTestMarker)'
91+
<!--
92+
Build the launcher MSI using Exec rather than MSBuild
93+
Also, never use the test marker for the launcher. It's going to corrupt things anyway, so we'll
94+
just disable it by default.
95+
-->
96+
<Exec Command='msbuild ..\launcher\launcher.wixproj /p:Platform=x86 /p:ReleaseUri="$(ReleaseUri)" /p:OutputPath="$(BuildPath.TrimEnd(`\`))" /p:OutputSuffix=$(Platform) /p:BuildForRelease=$(BuildForRelease) /p:UseTestMarker=false'
9397
ContinueOnError="false" />
9498
</Target>
9599

Tools/msi/bundle/bundle.wxs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,26 @@
2222

2323
<Variable Name="ShortVersion" Value="$(var.MajorVersionNumber).$(var.MinorVersionNumber)" />
2424
<Variable Name="ShortVersionNoDot" Value="$(var.MajorVersionNumber)$(var.MinorVersionNumber)" />
25-
<Variable Name="WinVer" Value="$(var.MajorVersionNumber).$(var.MinorVersionNumber)$(var.Suffix32)" />
26-
<Variable Name="WinVerNoDot" Value="$(var.MajorVersionNumber)$(var.MinorVersionNumber)$(var.Suffix32)" />
25+
<Variable Name="WinVer" Value="$(var.MajorVersionNumber).$(var.MinorVersionNumber)$(var.PyArchExt)$(var.PyTestExt)" />
26+
<Variable Name="WinVerNoDot" Value="$(var.MajorVersionNumber)$(var.MinorVersionNumber)$(var.PyArchExt)$(var.PyTestExt)" />
2727

2828
<Variable Name="InstallAllUsers" Value="0" bal:Overridable="yes" />
29+
<?ifndef PyTestExt ?>
2930
<Variable Name="InstallLauncherAllUsers" Value="1" bal:Overridable="yes" />
31+
<?else ?>
32+
<Variable Name="InstallLauncherAllUsers" Value="0" />
33+
<?endif ?>
3034
<Variable Name="TargetDir" Value="" bal:Overridable="yes" />
3135
<?if $(var.Platform)~="x64" ?>
32-
<Variable Name="DefaultAllUsersTargetDir" Value="[ProgramFiles64Folder]$(var.TestPrefix)Python[WinVerNoDot]" bal:Overridable="yes" />
36+
<Variable Name="DefaultAllUsersTargetDir" Value="[ProgramFiles64Folder]Python[WinVerNoDot]" bal:Overridable="yes" />
3337
<Variable Name="TargetPlatform" Value="x64" />
3438
<?else ?>
35-
<Variable Name="DefaultAllUsersTargetDir" Value="[ProgramFilesFolder]$(var.TestPrefix)Python[WinVerNoDot]" bal:Overridable="yes" />
39+
<Variable Name="DefaultAllUsersTargetDir" Value="[ProgramFilesFolder]Python[WinVerNoDot]" bal:Overridable="yes" />
3640
<Variable Name="TargetPlatform" Value="x86" />
3741
<?endif ?>
38-
<Variable Name="DefaultJustForMeTargetDir" Value="[LocalAppDataFolder]Programs\$(var.TestPrefix)Python\Python[WinVerNoDot]" bal:Overridable="yes" />
39-
<Variable Name="OptionalFeaturesRegistryKey" Value="Software\$(var.TestPrefix)Python\PythonCore\[WinVer]\InstalledFeatures" />
40-
<Variable Name="TargetDirRegistryKey" Value="Software\$(var.TestPrefix)Python\PythonCore\[WinVer]\InstallPath" />
42+
<Variable Name="DefaultJustForMeTargetDir" Value="[LocalAppDataFolder]Programs\Python\Python[WinVerNoDot]" bal:Overridable="yes" />
43+
<Variable Name="OptionalFeaturesRegistryKey" Value="Software\Python\PythonCore\[WinVer]\InstalledFeatures" />
44+
<Variable Name="TargetDirRegistryKey" Value="Software\Python\PythonCore\[WinVer]\InstallPath" />
4145

4246
<!--
4347
An empty string will use the other defaults based on InstallAllUsers
@@ -48,7 +52,11 @@
4852
<Variable Name="DefaultCustomTargetDir" Value="" bal:Overridable="yes" />
4953

5054
<Variable Name="InstallAllUsersState" Value="enabled" />
55+
<?ifndef PyTestExt ?>
5156
<Variable Name="InstallLauncherAllUsersState" Value="enabled" bal:Overridable="yes" />
57+
<?else ?>
58+
<Variable Name="InstallLauncherAllUsersState" Value="disable" bal:Overridable="yes" />
59+
<?endif ?>
5260
<Variable Name="CustomInstallLauncherAllUsersState" Value="[InstallLauncherAllUsersState]" />
5361
<Variable Name="TargetDirState" Value="enabled" />
5462
<Variable Name="CustomBrowseButtonState" Value="enabled" />
@@ -62,7 +70,12 @@
6270
<Variable Name="Include_tools" Value="1" bal:Overridable="yes" />
6371
<Variable Name="Include_tcltk" Value="1" bal:Overridable="yes" />
6472
<Variable Name="Include_pip" Value="1" bal:Overridable="yes" />
73+
<?ifndef PyTestExt ?>
6574
<Variable Name="Include_launcher" Value="1" bal:Overridable="yes" />
75+
<?else ?>
76+
<Variable Name="Include_launcher" Value="0" />
77+
<Variable Name="Include_launcherState" Value="disable" />
78+
<?endif ?>
6679
<Variable Name="Include_symbols" Value="0" bal:Overridable="yes" />
6780
<Variable Name="Include_debug" Value="0" bal:Overridable="yes" />
6881

Tools/msi/common.wxs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
33
<Fragment>
4-
<Property Id="REGISTRYKEY" Value="Software\$(var.TestPrefix)Python\PythonCore\$(var.ShortVersion)$(var.Suffix32)" />
4+
<Property Id="REGISTRYKEY" Value="Software\Python\PythonCore\$(var.ShortVersion)$(var.PyArchExt)$(var.PyTestExt)" />
55
</Fragment>
66

77
<Fragment>
@@ -105,7 +105,7 @@
105105
<Fragment>
106106
<DirectoryRef Id="TARGETDIR">
107107
<Directory Id="ProgramMenuFolder">
108-
<Directory Id="MenuDir" Name="$(var.TestPrefix)!(loc.ProductName)" />
108+
<Directory Id="MenuDir" Name="!(loc.ProductName)" />
109109
</Directory>
110110
</DirectoryRef>
111111
</Fragment>

Tools/msi/launcher/launcher_files.wxs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
<Fragment>
44
<ComponentGroup Id="launcher_exe">
55
<Component Id="py.exe" Directory="LauncherInstallDirectory" Guid="{B5107402-6958-461B-8B0A-4037D3327160}">
6-
<File Id="py.exe" Name="py$(var.TestPrefix).exe" Source="py.exe" KeyPath="yes" />
6+
<File Id="py.exe" Name="py.exe" Source="py.exe" KeyPath="yes" />
77
<RegistryValue Root="HKMU" Key="Software\Python\PyLauncher" Value="[#py.exe]" Type="string" />
88
</Component>
99
<Component Id="pyw.exe" Directory="LauncherInstallDirectory" Guid="{8E52B8CD-48BB-4D74-84CD-6238BCD11F20}">
10-
<File Id="pyw.exe" Name="pyw$(var.TestPrefix).exe" Source="pyw.exe" KeyPath="yes" />
10+
<File Id="pyw.exe" Name="pyw.exe" Source="pyw.exe" KeyPath="yes" />
1111
</Component>
1212

1313
<Component Id="launcher_path_cu" Directory="LauncherInstallDirectory" Guid="{95AEB930-367C-475C-A17E-A89BFCD4C670}">
1414
<Condition>NOT ALLUSERS=1</Condition>
1515

16-
<RegistryValue KeyPath="yes" Root="HKMU" Key="Software\$(var.TestPrefix)Python\PyLauncher" Name="InstallDir" Value="[LauncherInstallDirectory]" Type="string" />
16+
<RegistryValue KeyPath="yes" Root="HKMU" Key="Software\Python\PyLauncher" Name="InstallDir" Value="[LauncherInstallDirectory]" Type="string" />
1717
<Environment Id="PATH_CU" Action="set" Name="PATH" Part="first" Value="[LauncherInstallDirectory]" />
1818
</Component>
1919
<Component Id="launcher_path_lm" Directory="LauncherInstallDirectory" Guid="{4A41C365-4E27-4D38-A6D1-4A01B4A6500C}">
2020
<Condition>ALLUSERS=1</Condition>
21-
<RegistryValue KeyPath="yes" Root="HKMU" Key="Software\$(var.TestPrefix)Python\PyLauncher" Name="InstallDir" Value="[LauncherInstallDirectory]" Type="string" />
21+
<RegistryValue KeyPath="yes" Root="HKMU" Key="Software\Python\PyLauncher" Name="InstallDir" Value="[LauncherInstallDirectory]" Type="string" />
2222
</Component>
2323
</ComponentGroup>
2424
</Fragment>

0 commit comments

Comments
 (0)