Skip to content

Commit c4b7600

Browse files
committed
Improves support for building unofficial versions of the Windows installer.
1 parent d5963e6 commit c4b7600

File tree

8 files changed

+99
-41
lines changed

8 files changed

+99
-41
lines changed

Tools/msi/buildrelease.bat

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@
44
rem This script is intended for building official releases of Python.
55
rem To use it to build alternative releases, you should clone this file
66
rem and modify the following three URIs.
7-
rem
8-
rem The first two will ensure that your release can be installed
9-
rem alongside an official Python release, while the second specifies
10-
rem the URL that will be used to download installation files. The
11-
rem files available from this URL *will* conflict with your installer.
12-
rem Trust me, you don't want them, even if it seems like a good idea.
137

14-
set RELEASE_URI_X86=http://www.python.org/win32
15-
set RELEASE_URI_X64=http://www.python.org/amd64
16-
set DOWNLOAD_URL_BASE=https://www.python.org/ftp/python
17-
set DOWNLOAD_URL=
8+
rem These two will ensure that your release can be installed
9+
rem alongside an official Python release, by modifying the GUIDs used
10+
rem for all components.
11+
rem
12+
rem The following substitutions will be applied to the release URI:
13+
rem Variable Description Example
14+
rem {arch} architecture amd64, win32
15+
set RELEASE_URI=http://www.python.org/{arch}
16+
17+
rem This is the URL that will be used to download installation files.
18+
rem The files available from the default URL *will* conflict with your
19+
rem installer. Trust me, you don't want them, even if it seems like a
20+
rem good idea.
21+
rem
22+
rem The following substitutions will be applied to the download URL:
23+
rem Variable Description Example
24+
rem {version} version number 3.5.0
25+
rem {arch} architecture amd64, win32
26+
rem {releasename} release name a1, b2, rc3 (or blank for final)
27+
rem {msi} MSI filename core.msi
28+
set DOWNLOAD_URL=https://www.python.org/ftp/python/{version}/{arch}{releasename}/{msi}
1829

1930
set D=%~dp0
2031
set PCBUILD=%D%..\..\PCBuild\
@@ -90,14 +101,12 @@ if "%1" EQU "x86" (
90101
set BUILD_PLAT=Win32
91102
set OUTDIR_PLAT=win32
92103
set OBJDIR_PLAT=x86
93-
set RELEASE_URI=%RELEASE_URI_X86%
94104
) ELSE (
95105
call "%PCBUILD%env.bat" x86_amd64
96106
set BUILD=%PCBUILD%amd64\
97107
set BUILD_PLAT=x64
98108
set OUTDIR_PLAT=amd64
99109
set OBJDIR_PLAT=x64
100-
set RELEASE_URI=%RELEASE_URI_X64%
101110
)
102111

103112
if exist "%BUILD%en-us" (
@@ -157,10 +166,16 @@ echo -x64 Build x64 installers
157166
echo --build (-b) Incrementally build Python rather than rebuilding
158167
echo --skip-build (-B) Do not build Python (just do the installers)
159168
echo --skip-doc (-D) Do not build documentation
160-
echo --download Specify the full download URL for MSIs (should include {2})
169+
echo --download Specify the full download URL for MSIs
161170
echo --test Specify the test directory to run the installer tests
162171
echo -h Display this help information
163172
echo.
164173
echo If no architecture is specified, all architectures will be built.
165174
echo If --test is not specified, the installer tests are not run.
166-
echo.
175+
echo.
176+
echo The following substitutions will be applied to the download URL:
177+
echo Variable Description Example
178+
echo {version} version number 3.5.0
179+
echo {arch} architecture amd64, win32
180+
echo {releasename} release name a1, b2, rc3 (or blank for final)
181+
echo {msi} MSI filename core.msi

Tools/msi/bundle/bundle.targets

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
<OutputPath>$(OutputPath)en-us\</OutputPath>
1717
<OutDir>$(OutputPath)</OutDir>
1818

19-
<DownloadUrl Condition="'$(DownloadUrl)' == '' and '$(DownloadUrlBase)' != ''">$(DownloadUrlBase.TrimEnd(`/`))/$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)/$(ArchName)$(ReleaseLevelName)/</DownloadUrl>
20-
<DefineConstants Condition="'$(DownloadUrl)' != ''">$(DefineConstants);DownloadUrl=$(DownloadUrl){2}</DefineConstants>
19+
<!-- See Tools/msi/buildrelease.bat for help on configuring the download URL -->
20+
<DownloadUrl Condition="'$(DownloadUrl)' == '' and '$(DownloadUrlBase)' != ''">$(DownloadUrlBase.TrimEnd(`/`))/{version}/{arch}{releasename}/{msi}</DownloadUrl>
21+
<DefineConstants Condition="'$(DownloadUrl)' != ''">$(DefineConstants);DownloadUrl=$(DownloadUrl.Replace(`{version}`, `$(MajorVersionNumber).$(MinorVersionNumber).$(MicroVersionNumber)`).Replace(`{arch}`, `$(ArchName)`).Replace(`{releasename}`, `$(ReleaseName)`).Replace(`{msi}`, `{2}`))</DefineConstants>
2122
<DefineConstants Condition="'$(DownloadUrl)' == ''">$(DefineConstants);DownloadUrl={2}</DefineConstants>
2223
</PropertyGroup>
2324

@@ -88,7 +89,7 @@
8889

8990
<Target Name="BuildLauncher" BeforeTargets="BeforeBuild" Condition="'$(RebuildAll)' != 'false'">
9091
<!-- Build the launcher MSI using Exec rather than MSBuild -->
91-
<Exec Command='msbuild ..\launcher\launcher.wixproj /p:Platform=x86 /p:OutputPath="$(BuildPath.TrimEnd(`\`))" /p:OutputSuffix=$(Platform) /p:BuildForRelease=$(BuildForRelease) /p:UseTestMarker=$(UseTestMarker)'
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)'
9293
ContinueOnError="false" />
9394
</Target>
9495

Tools/msi/bundle/bundle.wxs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
<PackageGroupRef Id="tools" />
8686
<PackageGroupRef Id="tcltk" />
8787
<PackageGroupRef Id="launcher" />
88+
<PackageGroupRef Id="pip" />
89+
<PackageGroupRef Id="packageinstall" />
8890
<PackageGroupRef Id="postinstall" />
8991
</Chain>
9092
</Bundle>

Tools/msi/bundle/packagegroups/launcher.wxs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
DownloadUrl="$(var.DownloadUrl)"
1010
ForcePerMachine="yes"
1111
EnableFeatureSelection="yes"
12+
Permanent="yes"
13+
Visible="yes"
1214
InstallCondition="(InstallAllUsers or InstallLauncherAllUsers) and Include_launcher" />
1315

1416
<MsiPackage Id="launcher_JustForMe"
@@ -17,6 +19,8 @@
1719
DownloadUrl="$(var.DownloadUrl)"
1820
ForcePerMachine="no"
1921
EnableFeatureSelection="yes"
22+
Permanent="yes"
23+
Visible="yes"
2024
InstallCondition="not (InstallAllUsers or InstallLauncherAllUsers) and Include_launcher" />
2125
</PackageGroup>
2226
</Fragment>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3+
<Fragment>
4+
<PackageGroup Id="packageinstall">
5+
<!--
6+
This is an example of installing a package using pip as part of main install.
7+
8+
For a network-only install, remove the Payload element and change the install
9+
command to specify the package and (optionally) version specifier.
10+
11+
<ExePackage Id="requests"
12+
SourceFile="py.exe"
13+
Compressed="yes"
14+
DisplayName="!(loc.CompileAllDescription)"
15+
InstallCommand='-$(var.ShortVersion)$(var.Suffix32) -m pip install requests-2.7.0-py2.py3-none-any.whl'
16+
UninstallCommand='-$(var.ShortVersion)$(var.Suffix32) -m pip uninstall -y requests'
17+
Vital="no"
18+
InstallCondition="Include_pip and not LauncherOnly">
19+
<Payload SourceFile="requests-2.7.0-py2.py3-none-any.whl"
20+
Compressed="$(var.CompressMSI)"
21+
DownloadUrl="$(var.DownloadUrl)" />
22+
</ExePackage>
23+
-->
24+
</PackageGroup>
25+
</Fragment>
26+
</Wix>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3+
<Fragment>
4+
<PackageGroup Id="pip">
5+
<MsiPackage Id="pip_AllUsers"
6+
SourceFile="pip.msi"
7+
Compressed="$(var.CompressMSI)"
8+
DownloadUrl="$(var.DownloadUrl)"
9+
ForcePerMachine="yes"
10+
InstallCondition="InstallAllUsers and Include_pip and not LauncherOnly">
11+
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
12+
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
13+
</MsiPackage>
14+
<MsiPackage Id="pip_JustForMe"
15+
SourceFile="pip.msi"
16+
Compressed="$(var.CompressMSI)"
17+
DownloadUrl="$(var.DownloadUrl)"
18+
ForcePerMachine="no"
19+
InstallCondition="not InstallAllUsers and Include_pip and not LauncherOnly">
20+
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
21+
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
22+
</MsiPackage>
23+
</PackageGroup>
24+
</Fragment>
25+
</Wix>

Tools/msi/bundle/packagegroups/postinstall.wxs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,6 @@
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
33
<Fragment>
44
<PackageGroup Id="postinstall">
5-
<MsiPackage Id="pip_AllUsers"
6-
SourceFile="pip.msi"
7-
Compressed="$(var.CompressMSI)"
8-
DownloadUrl="$(var.DownloadUrl)"
9-
ForcePerMachine="yes"
10-
InstallCondition="InstallAllUsers and Include_pip and not LauncherOnly">
11-
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
12-
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
13-
</MsiPackage>
14-
<MsiPackage Id="pip_JustForMe"
15-
SourceFile="pip.msi"
16-
Compressed="$(var.CompressMSI)"
17-
DownloadUrl="$(var.DownloadUrl)"
18-
ForcePerMachine="no"
19-
InstallCondition="not InstallAllUsers and Include_pip and not LauncherOnly">
20-
<MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
21-
<MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
22-
</MsiPackage>
23-
245
<MsiPackage Id="path_AllUsers"
256
SourceFile="path.msi"
267
Compressed="$(var.CompressMSI)"

Tools/msi/msi.props

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
1212
<Platform Condition="'$(Platform)' == ''">x86</Platform>
1313
<InstallScope Condition="'$(InstallScope)' != 'perMachine'">perUser</InstallScope>
14+
</PropertyGroup>
15+
16+
<Import Project="wix.props" />
17+
<Import Project="..\..\PCBuild\tcltk.props" />
18+
19+
<PropertyGroup>
1420
<!--
1521
This URI is used to generate the various GUIDs used by the installer.
1622
Installers built with the same URI will upgrade each other or block
@@ -21,17 +27,15 @@
2127
that intend to bundle Python should rebuild these modules with their
2228
own URI to avoid conflicting with the official releases.
2329
24-
The official releases are built with http://www.python.org/.
30+
The official releases use "http://www.python.org/$(ArchName)"
2531
2632
This is not the same as the DownloadUrl property used in the bundle
2733
projects.
2834
-->
29-
<ReleaseUri Condition="'$(ReleaseUri)' == ''">$(ComputerName)</ReleaseUri>
35+
<ReleaseUri Condition="'$(ReleaseUri)' == ''">$(ComputerName)/$(ArchName)/</ReleaseUri>
3036
<ReleaseUri Condition="!$(ReleaseUri.EndsWith(`/`))">$(ReleaseUri)/</ReleaseUri>
3137
</PropertyGroup>
3238

33-
<Import Project="wix.props" />
34-
<Import Project="..\..\PCBuild\tcltk.props" />
3539

3640
<ItemGroup>
3741
<Compile Include="$(MSBuildThisFileDirectory)common.wxs" />
@@ -150,7 +154,7 @@
150154
<Target Name="_GenerateGuids" AfterTargets="PrepareForBuild">
151155
<PropertyGroup>
152156
<_Uuids>@(_Uuid->'("%(Identity)", "$(MajorVersionNumber).$(MinorVersionNumber)/%(Uri)")',',')</_Uuids>
153-
<_GenerateCommand>import uuid; print('\n'.join('{}={}'.format(i, uuid.uuid5(uuid.UUID('c8d9733e-a70c-43ff-ab0c-e26456f11083'), '$(ReleaseUri)' + j)) for i,j in [$(_Uuids.Replace(`"`,`'`))]))</_GenerateCommand>
157+
<_GenerateCommand>import uuid; print('\n'.join('{}={}'.format(i, uuid.uuid5(uuid.UUID('c8d9733e-a70c-43ff-ab0c-e26456f11083'), '$(ReleaseUri.Replace(`{arch}`, `$(ArchName)`))' + j)) for i,j in [$(_Uuids.Replace(`"`,`'`))]))</_GenerateCommand>
154158
</PropertyGroup>
155159

156160
<Exec Command='"$(PythonExe)" -c "$(_GenerateCommand)" &gt; "$(IntermediateOutputPath)$(OutputName)guids.txt"'

0 commit comments

Comments
 (0)