Debian Codegraph @

docs/en/reference/platforms/windows/index.md

raw
1 # Windows
2
3 <table class="host-platform-support-table">
4 <colgroup>
5 <col style="width: 11%" />
6 <col style="width: 10%" />
7 <col style="width: 7%" />
8 <col style="width: 5%" />
9 <col style="width: 6%" />
10 <col style="width: 5%" />
11 <col style="width: 5%" />
12 <col style="width: 7%" />
13 <col style="width: 11%" />
14 <col style="width: 7%" />
15 <col style="width: 10%" />
16 </colgroup>
17 <thead>
18 <tr>
19 <th colspan="11"><a href="../../../reference/platforms">Host Platform Support</a></th>
20 </tr>
21 <tr>
22 <th colspan="2">macOS</th>
23 <th colspan="5">Windows</th>
24 <th colspan="4">Linux</th>
25 </tr>
26 <tr>
27 <th>x86‑64</th>
28 <th>arm64</th>
29 <th>x86</th>
30 <th colspan="2">x86‑64</th>
31 <th colspan="2">arm64</th>
32 <th>x86</th>
33 <th>x86‑64</th>
34 <th>arm</th>
35 <th>arm64</th>
36 </tr>
37 </thead>
38 <tbody>
39 <tr>
40 <td></td>
41 <td></td>
42 <td></td>
43 <td colspan="2">{{ ci_tested }}</td>
44 <td colspan="2"></td>
45 <td></td>
46 <td></td>
47 <td></td>
48 <td></td>
49 </tr>
50 </tbody>
51 </table>
52
53 Briefcase supports two output formats for Windows apps:
54
55 - A [Windows app folder][windows-app-folder] with a pre-compiled binary; and
56 - A [Visual Studio project][visual-studio-project] which can be used to build an app with a customized binary.
57
58 The default output format for Windows is a [Windows app folder][windows-app-folder].
59
60 Configuration options between the [Windows app folder][windows-app-folder] and [Visual Studio project][visual-studio-project] formats are identical.
61
62 ## Prerequisites { #windows-prerequisites }
63
64 Briefcase requires installing Python 3.10+. You will also need a method for managing virtual environments (such as `venv`).
65
66 ## Packaging format
67
68 Briefcase supports two packaging formats for a Windows app:
69
70 1. As an MSI installer (the default output of `briefcase package windows`, or by using `briefcase package windows -p msi`); or
71 2. As a ZIP file containing all files needed to run the app (by using `briefcase package windows -p zip`).
72
73 Briefcase uses the [WiX Toolset](https://www.firegiant.com/wixtoolset/) to build an MSI installer for a Windows app.
74
75 ## Icon format
76
77 Windows apps installers use multi-format `.ico` icons; these icons should contain images in the following sizes:
78
79 - 16px
80 - 32px
81 - 48px
82 - 64px
83 - 256px
84
85 Windows Apps do not support splash screens or installer images.
86
87 ## Additional options
88
89 The following options can be provided at the command line when packaging Windows apps.
90
91 ### `--file-digest <digest>`
92
93 The digest algorithm to use for code signing files in the project. Defaults to `sha256`.
94
95 ### `--use-local-machine-stores`
96
97 By default, the certificate for code signing is assumed to be in the Current User's certificate stores. Use this flag to indicate the certificate is in the Local Machine's certificate stores.
98
99 ### `--cert-store <store>`
100
101 The internal Windows name for the certificate store containing the certificate for code signing. Defaults to `My`.
102
103 Common Stores:
104
105 | Windows internal name | Certificate store type |
106 |-----------------------|--------------------------------------------|
107 | My | Personal |
108 | CA | Intermediate Certification Authorities |
109 | AuthRoot | Third-Party Root Certification Authorities |
110 | TrustedPeople | Trusted People |
111 | TrustedPublisher | Trusted Publishers |
112 | Root | Trusted Root Certification Authorities |
113
114 ### `--timestamp-url <url>`
115
116 The URL of the Timestamp Authority server to timestamp the code signing. Defaults to `http://timestamp.digicert.com`.
117
118 ### `--timestamp-digest <url>`
119
120 The digest algorithm to request the Timestamp Authority server uses for the timestamp for code signing. Defaults to `sha256`.
121
122 ## Application configuration
123
124 The following options can be added to the `tool.briefcase.app.<appname>.windows` section of your `pyproject.toml` file.
125
126 ### `installer_path`
127
128 The name of a directory in the package bundle that can be used to store post-install and
129 pre-uninstall scripts. Defaults to `_installer`.
130
131 ### `post_install_script`
132
133 /// note | Only used for MSI packaging
134 ///
135
136 A path, relative to the project root, to a Windows `.bat` file that will be executed during installation, after the installer content has been unpacked. Its working directory will be the installed location.
137
138 ### `pre_uninstall_script`
139
140 /// note | Only used for MSI packaging
141 ///
142
143 A path, relative to the project root, to a Windows `.bat` file that will be executed during uninstallation, before the installed content is removed. Its working directory will be the installed location.
144
145 ### `system_installer`
146
147 Controls whether the app will be installed as a per-user or per-machine app. Per-machine apps are "system" apps, and require admin permissions to run the installer; however, they are installed once and shared between all users on a computer.
148
149 If `true` the installer will attempt to install the app as a per-machine app, available to all users. If `false`, the installer will install as a per-user app. If undefined the installer will ask the user for their preference.
150
151 ### `use_full_install_path`
152
153 Controls whether the app will be installed using a path which includes both the application name *and* the company or developer's name. If `true` (the default), the app will be installed to `Program Files<Author Name><Project Name>`. If `false`, it will be installed to `Program Files<Project Name>`. Using the full path makes sense for larger companies with multiple applications, but less so for a solo developer.
154
155 ### `version_triple`
156
157 Python and Briefcase allow any valid [PEP440 version number](https://peps.python.org/pep-0440/) as a [`version`][] specifier. However, MSI installers require a strict integer triple version number. Many PEP440-compliant version numbers, such as "1.2", "1.2.3b3", and "1.2.3.4", are invalid for MSI installers.
158
159 Briefcase will attempt to convert your [`version`][] into a valid MSI value by extracting the first three parts of the main series version number (excluding pre, post and dev version indicators), padding with zeros if necessary:
160
161 > - `1.2` becomes `1.2.0`
162 > - `1.2b4` becomes `1.2.0`
163 > - `1.2.3b3` becomes `1.2.3`
164 > - `1.2.3.4` becomes `1.2.3`.
165
166 However, if you need to override this default value, you can define [`version_triple`][] in your app settings. If provided, this value will be used in the MSI configuration file instead of the auto-generated value.
167
168 ## Installer/uninstaller options
169
170 Windows MSI installers are able to present a panel of optional features to the user as part of the installation or uninstallation process. These features are binary flags which can then be used by a [post-install script][post_install_script] to perform additional installation behaviors, or by a [pre-uninstall script][pre_uninstall_script] to perform additional uninstallation behaviors.
171
172 Installer and uninstaller options are defined using a TOML array of tables. Up to 4 installer options and 4 uninstaller options can be defined. Each option is in a group named `[[ toga.briefcase.app.<app name>.install_option ]]` or `[[ toga.briefcase.app.<app name>.uninstall_option ]]`, which must define the following keys:
173
174 ### `install_option.name` / `uninstall_option.name`
175
176 An identifier for the option. This name must be a valid Python identifier; the list of options specified for an app must be unique when converted into upper case (i.e., you cannot have `value` and `VALUE` in the same configuration). Names must be unique across both `install_options` *and* `uninstall_options`.
177
178 ### `install_option.title` / `uninstall_option.title`
179
180 A short human-readable label describing the option, as a string.
181
182 ### `install_option.description` / `uninstall_option.description`
183
184 A longer description of the purpose of the option, as a string.
185
186 ### `install_option.default` / `uninstall_option.default`
187
188 A Boolean describing the initial value of the option in the GUI. If not provided, defaults to `False`.
189
190 ### Using options
191
192 When an installer option is defined, the value of the option will be made available to the post-install or pre-uninstall script as an environment variable. For example, if you define an option with a name of `foo`, an environment variable of `OPTION_FOO` will be defined, with a value of 1 if the option has been selected by the user, and 0 if the option has not been selected.
193
194 In the post-install script, the `ALLUSERS` environment variable will be set; its value will be 1 if the app has been installed for all users, or 0 if it has only been installed for the current user. The `INSTALLER_PATH` environment variable will be set to the path of the MSI file.
195
196 If a user uninstalls software by clicking "uninstall" through the Windows "Remove software" interface, the uninstall options will not be displayed to the user. The pre-uninstall script *will* be executed, but the uninstall options will assume their default values. The uninstall GUI is only displayed if the user re-runs the installer manually, or if the user specifies the "Modify" option in the Windows "Remove software" interface. This is a quirk of the Windows uninstall tooling.
197
198 ## Platform quirks
199
200 ### Use caution with `--update-support`
201
202 Care should be taken when using the `--update-support` option to the `update`, `build` or `run` commands. Support packages in Windows apps are overlaid with app content, so it isn't possible to remove all old support files before installing new ones.
203
204 Briefcase will unpack the new support package without cleaning up existing support package content. This *should* work; however, ensure a reproducible release artefacts, it is advisable to perform a clean app build before release.
205
206 ### Packaging with `--adhoc-sign`
207
208 Using the `--adhoc-sign` option on Windows results in no signing being performed on the packaged app. This will result in your application being flagged as coming from an unverified publisher. This may limit who is able to install your app.
209
210 ### Tkinter is not available
211
212 Briefcase uses the official [Python.org Windows Embeddable package](https://docs.python.org/3/using/windows.html#windows-embeddable) to provide Python binaries for the Windows app. This embeddable distribution is missing some standard library modules that would be part of a normal Python.org install - most notably `tkinter`. This is due to the difficulty in distributing the Tk libraries needed by Tkinter in a way that is compatible with the Windows embedded binary format.
213
214 ### Maintaining a clean registry with MSI installers
215
216 If you are using an MSI installer, it is important to ensure that you leave installed artefacts in a "clean" state - especially if you are using a post-install or pre-uninstall script.
217
218 The MSI installer format can be thought of as managing a database - the MSI file describes a "transaction" of files that will be installed; when an app is uninstalled, that transaction is reverted, and all the installed files are removed. The transaction is tracked using the system registry. In most simple cases, running an MSI uninstaller will remove all the registry keys that were added by the MSI installer. However, there are some cases where this will not happen.
219
220 If you write files into the application folder, or you use a post-install or pre-uninstall script that modifies files in the application folder, you must ensure that everything that is installed by the MSI can be removed by the MSI on uninstallation. If the uninstallation process cannot remove files or directories that were originally added by the installer - either because the files have been removed, or because a folder isn't empty - then registry entries tied to that installer will remain in the registry after completion of the installation.
221
222 For example, consider an installer that creates a `data` folder in the app, containing 2 files `a.dat` and `b.dat`. The MSI installer has a post-installation script that deletes `b.dat`, and adds `c.dat`. When the uninstallation process is executed, registry entries for `data/b.dat` and `data` will remain in the registry. A well-behaved app should *not* delete content that the MSI app installed; and it should not leave content in locations that would prevent the MSI from removing content that the MSI installed.