Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 1 | Quick Build Info |
| 2 | ================ |
Martin v. Löwis | 8ffe9ab | 2004-08-22 13:34:34 +0000 | [diff] [blame] | 3 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 4 | For testing, the installer should be built with the Tools/msi/build.bat |
| 5 | script: |
Martin v. Löwis | 8ffe9ab | 2004-08-22 13:34:34 +0000 | [diff] [blame] | 6 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 7 | build.bat [-x86] [-x64] [--doc] |
Martin v. Löwis | 8ffe9ab | 2004-08-22 13:34:34 +0000 | [diff] [blame] | 8 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 9 | For an official release, the installer should be built with the |
| 10 | Tools/msi/buildrelease.bat script and environment variables: |
Martin v. Löwis | 8ffe9ab | 2004-08-22 13:34:34 +0000 | [diff] [blame] | 11 | |
Steve Dower | b85b4275 | 2015-07-08 22:43:48 -0700 | [diff] [blame] | 12 | set PYTHON=<path to Python 2.7 or 3.4> |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 13 | set SPHINXBUILD=<path to sphinx-build.exe> |
Anthony Shaw | 78018bb | 2020-01-03 04:32:55 +1100 | [diff] [blame] | 14 | set PATH=<path to Git (git.exe)>; |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 15 | <path to HTML Help Compiler (hhc.exe)>;%PATH% |
Martin v. Löwis | 8ffe9ab | 2004-08-22 13:34:34 +0000 | [diff] [blame] | 16 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 17 | buildrelease.bat [-x86] [-x64] [-D] [-B] |
| 18 | [-o <output directory>] [-c <certificate name>] |
| 19 | |
| 20 | See the Building the Installer section for more information. |
| 21 | |
| 22 | Overview |
| 23 | ======== |
| 24 | |
| 25 | Python is distributed on Windows as an installer that will configure the |
| 26 | user's system. This allows users to have a functioning copy of Python |
| 27 | without having to build it themselves. |
| 28 | |
| 29 | The main tasks of the installer are: |
| 30 | |
| 31 | * copy required files into the expected layout |
| 32 | * configure system settings so the installation can be located by |
| 33 | other programs |
| 34 | * add entry points for modifying, repairing and uninstalling Python |
| 35 | * make it easy to launch Python, its documentation, and IDLE |
| 36 | |
| 37 | Each of these is discussed in a later section of this document. |
| 38 | |
| 39 | Structure of the Installer |
| 40 | ========================== |
| 41 | |
| 42 | The installer is structured as a 'layout', which consists of a number of |
| 43 | CAB and MSI files and a single EXE. |
| 44 | |
| 45 | The EXE is the main entry point into the installer. It contains the UI |
| 46 | and command-line logic, as well as the ability to locate and optionally |
| 47 | download other parts of the layout. |
| 48 | |
| 49 | Each MSI contains the logic required to install a component or feature |
| 50 | of Python. These MSIs should not be launched directly by users. MSIs can |
| 51 | be embedded into the EXE or automatically downloaded as needed. |
| 52 | |
| 53 | Each CAB contains the files making up a Python installation. CABs are |
| 54 | embedded into their associated MSI and are never seen by users. |
| 55 | |
| 56 | MSIs are only required when the related feature or component is being |
| 57 | installed. When components are not selected for installation, the |
| 58 | associated MSI is not downloaded. This allows the installer to offer |
| 59 | options to install debugging symbols and binaries without increasing |
| 60 | the initial download size by separating them into their own MSIs. |
| 61 | |
| 62 | Building the Installer |
| 63 | ====================== |
| 64 | |
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 65 | Before building the installer, download extra build dependencies using |
| 66 | Tools\msi\get_externals.bat. (Note that this is in addition to the |
Stefan Grönke | f1502d0 | 2017-09-25 18:58:10 +0200 | [diff] [blame] | 67 | similarly named file in PCbuild.) |
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 68 | |
Vinay Sajip | c536bee | 2018-07-29 10:05:20 +0100 | [diff] [blame] | 69 | One of the dependencies used in builds is WiX, a toolset that lets developers |
| 70 | create installers for Windows Installer, the Windows installation engine. WiX |
| 71 | has a dependency on the Microsoft .NET Framework Version 3.5 (which may not be |
| 72 | configured on recent versions of Windows, such as Windows 10). If you are |
| 73 | building on a recent Windows version, use the Control Panel (Programs | Programs |
| 74 | and Features | Turn Windows Features on or off) and ensure that the entry |
| 75 | ".NET Framework 3.5 (includes .NET 2.0 and 3.0)" is enabled. |
| 76 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 77 | For testing, the installer should be built with the Tools/msi/build.bat |
| 78 | script: |
| 79 | |
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 80 | build.bat [-x86] [-x64] [--doc] [--test-marker] [--pack] |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 81 | |
| 82 | This script will build the required configurations of Python and |
Stefan Grönke | f1502d0 | 2017-09-25 18:58:10 +0200 | [diff] [blame] | 83 | generate an installer layout in PCbuild/(win32|amd64)/en-us. |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 84 | |
| 85 | Specify -x86 and/or -x64 to build for each platform. If neither is |
| 86 | specified, both platforms will be built. Currently, both the debug and |
| 87 | release versions of Python are required for the installer. |
| 88 | |
| 89 | Specify --doc to build the documentation (.chm) file. If the file is not |
| 90 | available, it will simply be excluded from the installer. Ensure |
| 91 | %PYTHON% and %SPHINXBUILD% are set when passing this option. You may |
| 92 | also set %HTMLHELP% to the Html Help Compiler (hhc.exe), or put HHC on |
| 93 | your PATH or in externals/. |
| 94 | |
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 95 | Specify --test-marker to build an installer that works side-by-side with |
| 96 | an official Python release. All registry keys and install locations will |
| 97 | include an extra marker to avoid overwriting files. This marker is |
| 98 | currently an 'x' prefix, but may change at any time. |
| 99 | |
| 100 | Specify --pack to build an installer that does not require all MSIs to |
| 101 | be available alongside. This takes longer, but is easier to share. |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 102 | |
| 103 | |
| 104 | For an official release, the installer should be built with the |
| 105 | Tools/msi/buildrelease.bat script: |
| 106 | |
Steve Dower | b85b4275 | 2015-07-08 22:43:48 -0700 | [diff] [blame] | 107 | set PYTHON=<path to Python 2.7 or 3.4> |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 108 | set SPHINXBUILD=<path to sphinx-build.exe> |
Anthony Shaw | 78018bb | 2020-01-03 04:32:55 +1100 | [diff] [blame] | 109 | set PATH=<path to Git (git.exe)>; |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 110 | <path to HTML Help Compiler (hhc.exe)>;%PATH% |
| 111 | |
| 112 | buildrelease.bat [-x86] [-x64] [-D] [-B] |
| 113 | [-o <output directory>] [-c <certificate name>] |
| 114 | |
| 115 | Specify -x86 and/or -x64 to build for each platform. If neither is |
| 116 | specified, both platforms will be built. Currently, both the debug and |
| 117 | release versions of Python are required for the installer. |
| 118 | |
| 119 | Specify -D to skip rebuilding the documentation. The documentation is |
| 120 | required for a release and the build will fail if it is not available. |
| 121 | |
| 122 | Specify -B to skip rebuilding Python. This is useful to only rebuild the |
| 123 | installer layout after a previous call to buildrelease.bat. |
| 124 | |
| 125 | Specify -o to set an output directory. The installer layouts will be |
| 126 | copied to platform-specific subdirectories of this path. |
| 127 | |
| 128 | Specify -c to choose a code-signing certificate to be used for all the |
| 129 | signable binaries in Python as well as each file making up the |
| 130 | installer. Official releases of Python must be signed. |
| 131 | |
| 132 | Ensure %PYTHON% and %SPHINXBUILD% are set when passing this option. You |
| 133 | may also set %HTMLHELP% to the Html Help Compiler (hhc.exe), or put HHC |
Anthony Shaw | 78018bb | 2020-01-03 04:32:55 +1100 | [diff] [blame] | 134 | on your PATH or in externals/. You will also need Git (git.exe) on |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 135 | your PATH. |
| 136 | |
| 137 | If WiX is not found on your system, it will be automatically downloaded |
| 138 | and extracted to the externals/ directory. |
| 139 | |
| 140 | To manually build layouts of the installer, build one of the projects in |
| 141 | the bundle folder. |
| 142 | |
| 143 | msbuild bundle\snapshot.wixproj |
| 144 | msbuild bundle\releaseweb.wixproj |
| 145 | msbuild bundle\releaselocal.wixproj |
| 146 | msbuild bundle\full.wixproj |
| 147 | |
| 148 | snapshot.wixproj produces a test installer versioned based on the date. |
| 149 | |
| 150 | releaseweb.wixproj produces a release installer that does not embed any |
| 151 | of the layout. |
| 152 | |
| 153 | releaselocal.wixproj produces a release installer that embeds the files |
| 154 | required for a default installation. |
| 155 | |
| 156 | full.wixproj produces a test installer that embeds the entire layout. |
| 157 | |
| 158 | The following properties may be passed when building these projects. |
| 159 | |
| 160 | /p:BuildForRelease=(true|false) |
| 161 | When true, adds extra verification to ensure a complete installer is |
Steve Dower | f569092 | 2019-06-21 14:28:46 -0700 | [diff] [blame] | 162 | produced. Defaults to false. |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 163 | |
| 164 | /p:ReleaseUri=(any URI) |
| 165 | Used to generate unique IDs for the installers to allow side-by-side |
| 166 | installation. Forks of Python can use the same installer infrastructure |
| 167 | by providing a unique URI for this property. It does not need to be an |
| 168 | active internet address. Defaults to $(ComputerName). |
| 169 | |
| 170 | Official releases use http://www.python.org/(architecture name) |
| 171 | |
| 172 | /p:DownloadUrlBase=(any URI) |
| 173 | Specifies the base of a URL where missing parts of the installer layout |
| 174 | can be downloaded from. The build version and architecture will be |
| 175 | appended to create the full address. If omitted, missing components will |
| 176 | not be automatically downloaded. |
| 177 | |
| 178 | /p:DownloadUrl=(any URI) |
| 179 | Specifies the full URL where missing parts of the installer layout can |
| 180 | be downloaded from. Should normally include '{2}', which will be |
| 181 | substituted for the filename. If omitted, missing components will not be |
| 182 | automatically downloaded. If specified, this value overrides |
| 183 | DownloadUrlBase. |
| 184 | |
| 185 | /p:SigningCertificate=(certificate name) |
| 186 | Specifies the certificate to sign the installer layout with. If omitted, |
| 187 | the layout will not be signed. |
| 188 | |
| 189 | /p:RebuildAll=(true|false) |
| 190 | When true, rebuilds all of the MSIs making up the layout. Defaults to |
| 191 | true. |
| 192 | |
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 193 | Uploading the Installer |
| 194 | ======================= |
| 195 | |
| 196 | For official releases, the uploadrelease.bat script should be used. |
| 197 | |
| 198 | You will require PuTTY so that plink.exe and pscp.exe can be used, and your |
| 199 | SSH key can be activated in pageant.exe. PuTTY should be either on your path |
| 200 | or in %ProgramFiles(x86)%\PuTTY. |
| 201 | |
| 202 | To include signatures for each uploaded file, you will need gpg2.exe on your |
| 203 | path or have run get_externals.bat. You may also need to "gpg2.exe --import" |
| 204 | your key before running the upload script. |
| 205 | |
| 206 | uploadrelease.bat --host <host> --user <username> [--dry-run] [--no-gpg] |
| 207 | |
| 208 | The host is the URL to the server. This can be provided by the Release |
| 209 | Manager. You should be able to SSH to this address. |
| 210 | |
| 211 | The username is your own username, which you have permission to SSH into |
| 212 | the server containing downloads. |
| 213 | |
| 214 | Use --dry-run to display the generated upload commands without executing |
| 215 | them. Signatures for each file will be generated but not uploaded unless |
| 216 | --no-gpg is also passed. |
| 217 | |
| 218 | Use --no-gpg to suppress signature generation and upload. |
| 219 | |
| 220 | The default target directory (which appears in uploadrelease.proj) is |
| 221 | correct for official Python releases, but may be overridden with |
| 222 | --target <path> for other purposes. This path should generally not include |
| 223 | any version specifier, as that will be added automatically. |
| 224 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 225 | Modifying the Installer |
| 226 | ======================= |
| 227 | |
| 228 | The code for the installer is divided into three main groups: packages, |
| 229 | the bundle and the bootstrap application. |
| 230 | |
| 231 | Packages |
| 232 | -------- |
| 233 | |
| 234 | Packages appear as subdirectories of Tools/msi (other than the bundle/ |
| 235 | directory). The project file is a .wixproj and the build output is a |
| 236 | single MSI. Packages are built with the WiX Toolset. Some project files |
| 237 | share source files and use preprocessor directives to enable particular |
| 238 | features. These are typically used to keep the sources close when the |
| 239 | files are related, but produce multiple independent packages. |
| 240 | |
| 241 | A package is the smallest element that may be independently installed or |
| 242 | uninstalled (as used in this installer). For example, the test suite has |
| 243 | its own package, as users can choose to add or remove it after the |
| 244 | initial installation. |
| 245 | |
| 246 | All the files installed by a single package should be related, though |
| 247 | some packages may not install any files. For example, the pip package |
| 248 | executes the ensurepip package, but does not add or remove any of its |
| 249 | own files. (It is represented as a package because of its |
| 250 | installed/uninstalled nature, as opposed to the "precompile standard |
| 251 | library" option, for example.) Dependencies between packages are handled |
| 252 | by the bundle, but packages should detect when dependencies are missing |
| 253 | and raise an error. |
| 254 | |
| 255 | Packages that include a lot of files may use an InstallFiles element in |
| 256 | the .wixproj file to generate sources. See lib/lib.wixproj for an |
| 257 | example, and msi.targets and csv_to_wxs.py for the implementation. This |
| 258 | element is also responsible for generating the code for cleaning up and |
| 259 | removing __pycache__ folders in any directory containing .py files. |
| 260 | |
| 261 | All packages are built with the Tools/msi/common.wxs file, and so any |
| 262 | directory or property in this file may be referenced. Of particular |
| 263 | interest: |
| 264 | |
| 265 | REGISTRYKEY (property) |
| 266 | The registry key for the current installation. |
| 267 | |
| 268 | InstallDirectory (directory) |
| 269 | The root install directory for the current installation. Subdirectories |
| 270 | are also specified in this file (DLLs, Lib, etc.) |
| 271 | |
| 272 | MenuDir (directory) |
| 273 | The Start Menu folder for the current installation. |
| 274 | |
| 275 | UpgradeTable (property) |
| 276 | Every package should reference this property to include upgrade |
| 277 | information. |
| 278 | |
Steve Dower | b85b4275 | 2015-07-08 22:43:48 -0700 | [diff] [blame] | 279 | OptionalFeature (Component) |
| 280 | Packages that may be enabled or disabled should reference this component |
| 281 | and have an OPTIONAL_FEATURES entry in the bootstrap application to |
| 282 | properly handle Modify and Upgrade. |
| 283 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 284 | The .wxl_template file is specially handled by the build system for this |
| 285 | project to perform {{substitutions}} as defined in msi.targets. They |
| 286 | should be included in projects as <WxlTemplate> items, where .wxl files |
| 287 | are normally included as <EmbeddedResource> items. |
| 288 | |
| 289 | Bundle |
| 290 | ------ |
| 291 | |
| 292 | The bundle is compiled to the main EXE entry point that for most users |
| 293 | will represent the Python installer. It is built from Tools/msi/bundle |
| 294 | with packages references in Tools/msi/bundle/packagegroups. |
| 295 | |
| 296 | Build logic for the bundle is in bundle.targets, but should be invoked |
| 297 | through one of the .wixproj files as described in Building the |
| 298 | Installer. |
| 299 | |
| 300 | The UI is separated between Default.thm (UI layout), Default.wxl |
| 301 | (strings), bundle.wxs (properties) and the bootstrap application. |
| 302 | Bundle.wxs also contains the chain, which is the list of packages to |
| 303 | install and the order they should be installed in. These refer to named |
| 304 | package groups in bundle/packagegroups. |
| 305 | |
| 306 | Each package group specifies one or more packages to install. Most |
| 307 | packages require two separate entries to support both per-user and |
| 308 | all-users installations. Because these reuse the same package, it does |
| 309 | not increase the overall size of the package. |
| 310 | |
| 311 | Package groups refer to payload groups, which allow better control over |
| 312 | embedding and downloading files than the default settings. Whether files |
| 313 | are embedded and where they are downloaded from depends on settings |
| 314 | created by the project files. |
| 315 | |
| 316 | Package references can include install conditions that determine when to |
| 317 | install the package. When a package is a dependency for others, the |
| 318 | condition should be crafted to ensure it is installed. |
| 319 | |
| 320 | MSI packages are installed or uninstalled based on their current state |
| 321 | and the install condition. This makes them most suitable for features |
| 322 | that are clearly present or absent from the user's machine. |
| 323 | |
| 324 | EXE packages are executed based on a customisable condition that can be |
| 325 | omitted. This makes them suitable for pre- or post-install tasks that |
| 326 | need to run regardless of whether features have been added or removed. |
| 327 | |
| 328 | Bootstrap Application |
| 329 | --------------------- |
| 330 | |
| 331 | The bootstrap application is a C++ application that controls the UI and |
| 332 | installation. While it does not directly compile into the main EXE of |
| 333 | the installer, it forms the main active component. Most of the |
| 334 | installation functionality is provided by WiX, and so the bootstrap |
| 335 | application is predominantly responsible for the code behind the UI that |
| 336 | is defined in the Default.thm file. The bootstrap application code is in |
| 337 | bundle/bootstrap and is built automatically when building the bundle. |
| 338 | |
| 339 | Installation Layout |
| 340 | =================== |
| 341 | |
| 342 | There are two installation layouts for Python on Windows, with the only |
| 343 | differences being supporting files. A layout is selected implicitly |
| 344 | based on whether the install is for all users of the machine or just for |
| 345 | the user performing the installation. |
| 346 | |
| 347 | The default installation location when installing for all users is |
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 348 | "%ProgramFiles%\Python3X" for the 64-bit interpreter and |
| 349 | "%ProgramFiles(x86)%\Python3X-32" for the 32-bit interpreter. (Note that |
| 350 | the latter path is equivalent to "%ProgramFiles%\Python3X-32" when |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 351 | running a 32-bit version of Windows.) This location requires |
| 352 | administrative privileges to install or later modify the installation. |
| 353 | |
| 354 | The default installation location when installing for the current user |
| 355 | is "%LocalAppData%\Programs\Python\Python3X" for the 64-bit interpreter |
| 356 | and "%LocalAppData%\Programs\Python\Python3X-32" for the 32-bit |
| 357 | interpreter. Only the current user can access this location. This |
| 358 | provides a suitable level of protection against malicious modification |
| 359 | of Python's files. |
| 360 | |
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 361 | (Default installation locations are set in Tools\msi\bundle\bundle.wxs.) |
| 362 | |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 363 | Within this install directory is the following approximate layout: |
| 364 | |
| 365 | .\python[w].exe The core executable files |
| 366 | .\DLLs Stdlib extensions (*.pyd) and dependencies |
| 367 | .\Doc Documentation (*.chm) |
| 368 | .\include Development headers (*.h) |
| 369 | .\Lib Standard library |
| 370 | .\Lib\test Test suite |
| 371 | .\libs Development libraries (*.lib) |
| 372 | .\Scripts Launcher scripts (*.exe, *.py) |
| 373 | .\tcl Tcl dependencies (*.dll, *.tcl and others) |
| 374 | .\Tools Tool scripts (*.py) |
| 375 | |
| 376 | When installed for all users, the following files are installed to |
| 377 | either "%SystemRoot%\System32" or "%SystemRoot%\SysWOW64" as |
| 378 | appropriate. For the current user, they are installed in the Python |
| 379 | install directory. |
| 380 | |
| 381 | .\python3x.dll The core interpreter |
| 382 | .\python3.dll The stable ABI reference |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 383 | |
| 384 | When installed for all users, the following files are installed to |
| 385 | "%SystemRoot%" (typically "C:\Windows") to ensure they are always |
| 386 | available on PATH. (See Launching Python below.) For the current user, |
Steve Dower | b85b4275 | 2015-07-08 22:43:48 -0700 | [diff] [blame] | 387 | they are installed in "%LocalAppData%\Programs\Python\PyLauncher". |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 388 | |
| 389 | .\py[w].exe PEP 397 launcher |
| 390 | |
| 391 | System Settings |
| 392 | =============== |
| 393 | |
| 394 | On installation, registry keys are created so that other applications |
| 395 | can locate and identify installations of Python. The locations of these |
| 396 | keys vary based on the install type. |
| 397 | |
| 398 | For 64-bit interpreters installed for all users, the root key is: |
| 399 | HKEY_LOCAL_MACHINE\Software\Python\PythonCore\3.X |
| 400 | |
| 401 | For 32-bit interpreters installed for all users on a 64-bit operating |
| 402 | system, the root key is: |
| 403 | HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python\PythonCore\3.X-32 |
| 404 | |
| 405 | For 32-bit interpreters installed for all users on a 32-bit operating |
| 406 | system, the root key is: |
| 407 | HKEY_LOCAL_MACHINE\Software\Python\PythonCore\3.X-32 |
| 408 | |
| 409 | For 64-bit interpreters installed for the current user: |
| 410 | HKEY_CURRENT_USER\Software\Python\PythonCore\3.X |
| 411 | |
| 412 | For 32-bit interpreters installed for the current user: |
| 413 | HKEY_CURRENT_USER\Software\Python\PythonCore\3.X-32 |
| 414 | |
| 415 | When the core Python executables are installed, a key "InstallPath" is |
| 416 | created within the root key with its default value set to the |
Steve Dower | b85b4275 | 2015-07-08 22:43:48 -0700 | [diff] [blame] | 417 | executable's install directory. A value named "ExecutablePath" is added |
| 418 | with the full path to the main Python interpreter, and a key |
| 419 | "InstallGroup" is created with its default value set to the product |
| 420 | name "Python 3.X". |
Steve Dower | bb24087 | 2015-02-05 22:08:48 -0800 | [diff] [blame] | 421 | |
| 422 | When the Python standard library is installed, a key "PythonPath" is |
| 423 | created within the root key with its default value set to the full path |
| 424 | to the Lib folder followed by the path to the DLLs folder, separated by |
| 425 | a semicolon. |
| 426 | |
| 427 | When the documentation is installed, a key "Help" is created within the |
| 428 | root key, with a subkey "Main Python Documentation" with its default |
| 429 | value set to the full path to the installed CHM file. |
| 430 | |
| 431 | |
| 432 | The py.exe launcher is installed as part of a regular Python install, |
| 433 | but using a separate mechanism that allows it to more easily span |
| 434 | versions of Python. As a result, it has different root keys for its |
| 435 | registry entries: |
| 436 | |
| 437 | When installed for all users on a 64-bit operating system, the |
| 438 | launcher's root key is: |
| 439 | HKEY_LOCAL_MACHINE\Software\Wow6432Node\Python\Launcher |
| 440 | |
| 441 | When installed for all users on a 32-bit operating system, the |
| 442 | launcher's root key is: |
| 443 | HKEY_LOCAL_MACHINE\Software\Python\Launcher |
| 444 | |
| 445 | When installed for the current user: |
| 446 | HKEY_CURRENT_USER\Software\Python\Launcher |
| 447 | |
| 448 | When the launcher is installed, a key "InstallPath" is created within |
| 449 | its root key with its default value set to the launcher's install |
| 450 | directory. File associations are also created for .py, .pyw, .pyc and |
| 451 | .pyo files. |
| 452 | |
| 453 | Launching Python |
| 454 | ================ |
| 455 | |
| 456 | When a feature offering user entry points in the Start Menu is |
| 457 | installed, a folder "Python 3.X" is created. Every shortcut should be |
| 458 | created within this folder, and each shortcut should include the version |
| 459 | and platform to allow users to identify the shortcut in a search results |
| 460 | page. |
| 461 | |
| 462 | The core Python executables creates a shortcut "Python 3.X (32-bit)" or |
| 463 | "Python 3.X (64-bit)" depending on the interpreter. |
| 464 | |
| 465 | The documentation creates a shortcut "Python 3.X 32-bit Manuals" or |
| 466 | "Python 3.X 64-bit Manuals". The documentation is identical for all |
| 467 | platforms, but the shortcuts need to be separate to avoid uninstallation |
| 468 | conflicts. |
| 469 | |
| 470 | Installing IDLE creates a shortcut "IDLE (Python 3.X 32-bit)" or "IDLE |
| 471 | (Python 3.X 64-bit)" depending on the interpreter. |
| 472 | |
| 473 | |
| 474 | For users who often launch Python from a Command Prompt, an option is |
| 475 | provided to add the directory containing python.exe to the user or |
| 476 | system PATH variable. If the option is selected, the install directory |
| 477 | and the Scripts directory will be added at the start of the system PATH |
| 478 | for an all users install and the user PATH for a per-user install. |
| 479 | |
| 480 | When the user only has one version of Python installed, this will behave |
| 481 | as expected. However, because Windows searches the system PATH before |
| 482 | the user PATH, users cannot override a system-wide installation of |
| 483 | Python on their PATH. Further, because the installer can only prepend to |
| 484 | the path, later installations of Python will take precedence over |
| 485 | earlier installations, regardless of interpreter version. |
| 486 | |
| 487 | Because it is not possible to automatically create a sensible PATH |
| 488 | configuration, users are recommended to use the py.exe launcher and |
| 489 | manually modify their PATH variable to add Scripts directories in their |
| 490 | preferred order. System-wide installations of Python should consider not |
| 491 | modifying PATH, or using an alternative technology to modify their |
| 492 | users' PATH variables. |
| 493 | |
| 494 | |
| 495 | The py.exe launcher is recommended because it uses a consistent and |
| 496 | sensible search order for Python installations. User installations are |
| 497 | preferred over system-wide installs, and later versions are preferred |
| 498 | regardless of installation order (with the exception that py.exe |
| 499 | currently prefers 2.x versions over 3.x versions without the -3 command |
| 500 | line argument). |
| 501 | |
| 502 | For both 32-bit and 64-bit interpreters, the 32-bit version of the |
| 503 | launcher is installed. This ensures that the search order is always |
| 504 | consistent (as the 64-bit launcher is subtly different from the 32-bit |
| 505 | launcher) and also avoids the need to install it multiple times. Future |
| 506 | versions of Python will upgrade the launcher in-place, using Windows |
| 507 | Installer's upgrade functionality to avoid conflicts with earlier |
| 508 | installed versions. |
| 509 | |
| 510 | When installed, file associations are created for .py, .pyc and .pyo |
| 511 | files to launch with py.exe and .pyw files to launch with pyw.exe. This |
| 512 | makes Python files respect shebang lines by default and also avoids |
| 513 | conflicts between multiple Python installations. |
| 514 | |
| 515 | |
| 516 | Repair, Modify and Uninstall |
| 517 | ============================ |
| 518 | |
| 519 | After installation, Python may be modified, repaired or uninstalled by |
| 520 | running the original EXE again or via the Programs and Features applet |
| 521 | (formerly known as Add or Remove Programs). |
| 522 | |
| 523 | Modifications allow features to be added or removed. The install |
| 524 | directory and kind (all users/single user) cannot be modified. Because |
| 525 | Windows Installer caches installation packages, removing features will |
| 526 | not require internet access unless the package cache has been corrupted |
| 527 | or deleted. Adding features that were not previously installed and are |
| 528 | not embedded or otherwise available will require internet access. |
| 529 | |
| 530 | Repairing will rerun the installation for all currently installed |
| 531 | features, restoring files and registry keys that have been modified or |
| 532 | removed. This operation generally will not redownload any files unless |
| 533 | the cached packages have been corrupted or deleted. |
| 534 | |
| 535 | Removing Python will clean up all the files and registry keys that were |
| 536 | created by the installer, as well as __pycache__ folders that are |
| 537 | explicitly handled by the installer. Python packages installed later |
| 538 | using a tool like pip will not be removed. Some components may be |
Steve Dower | d28a8a9 | 2015-10-23 09:50:49 -0700 | [diff] [blame] | 539 | installed by other installers and these will not be removed if another |
| 540 | product has a dependency on them. |
Martin v. Löwis | 8ffe9ab | 2004-08-22 13:34:34 +0000 | [diff] [blame] | 541 | |