Skip to content

Customize Briefcase's MSI installer#4609

Merged
abdnh merged 3 commits intobriefcasefrom
KNW-99
Mar 16, 2026
Merged

Customize Briefcase's MSI installer#4609
abdnh merged 3 commits intobriefcasefrom
KNW-99

Conversation

@abdnh
Copy link
Copy Markdown
Collaborator

@abdnh abdnh commented Mar 11, 2026

This customizes Briefcase's MSI installer to reimplement some features that exist in the NSIS installer.

Briefcase generates a WiX template from a cookiecutter template. The template config option can be used to specify a different template. This PR sets it to a fork of the official template on Windows. You can see our changes here: beeware/briefcase-windows-app-template@main...ankitects:briefcase-windows-app-template:anki

Changes

  • Add an option to create a desktop shortcut.
  • Abort installer if not compatible with the system. (must be 64-bit Windows 10+)
  • Prompt to close Anki if it's already running or any of its files in use. The NSIS installer only checks if the anki.exe process is running, while the standard MSI approach used here should handle the somewhat common issue where mpv.exe is left running in the background.

How to test

  • Build the installer on Windows: ./tools/ninja installer.
  • Run the installer at out/installer/dist/Anki-25.9.2.msi.
  • Confirm the option to create a desktop shortcut is displayed and working.
  • Try running the installer while Anki is open and confirm the prompt to close Anki is shown. According to my tests, the installer fails to close Anki when the main Anki process is running and the UI is visible, so a restart would be required (unless the user closes Anki manually before proceeding of course). In the case of a background mpv.exe process, I could confirm the installer manages to kill the process and proceed with the installation/uninstallation.
  • To test the Windows version check, you can temporarily invert the check at the start of the qt\installer\windows-template\{{ cookiecutter.format }}\{{ cookiecutter.app_name }}.wxs file (search for <Launch) to trigger the error.

Screenshots

image Screenshot 2026-03-12 181113 Screenshot 2026-03-12 171631

Closes #4604

@abdnh abdnh marked this pull request as ready for review March 12, 2026 17:24
@abdnh abdnh requested a review from fernandolins March 12, 2026 17:33
@abdnh abdnh merged commit d5a9721 into briefcase Mar 16, 2026
1 check passed
@abdnh abdnh deleted the KNW-99 branch March 16, 2026 14:22
abdnh added a commit to abdnh/anki that referenced this pull request Mar 30, 2026
Squashed commit of the following:

commit 7629a32
Merge: 40e19d3 011b54a
Author: Abdo <abdo@abdnh.net>
Date:   Mon Mar 30 20:17:05 2026 +0300

    Merge branch 'briefcase' into release-action

commit 011b54a
Merge: f44ab04 bd41a6e
Author: Abdo <abdo@abdnh.net>
Date:   Mon Mar 30 17:00:03 2026 +0300

    Merge branch 'main' into briefcase

commit f44ab04
Author: Abdo <abdo@abdnh.net>
Date:   Mon Mar 30 16:47:42 2026 +0300

    Update installer docs (ankitects#4645)

    Add a small section about the Briefcase/PyInstaller installer to
    docs/development.md.

commit ea04da5
Author: Abdo <abdo@abdnh.net>
Date:   Fri Mar 27 16:21:20 2026 +0300

    Use PyInstaller on Linux (ankitects#4638)

    ## Changes

    This changes the new installer to use PyInstaller instead of Briefcase
    on Linux. The main benefit is that PyInstaller bundles all dependencies
    with the app (including Python), while Briefcase relies on the system's
    Python matching the one linked to the app, which makes distribution and
    support for multiple distros really hard. See ankitects#4622 for some details.

    ## How to test

    - Build the installer: `./ninja installer`.
    - Run the executable under `./out/installer/dist/anki`.
    - If you have access to another (newer) Linux distro, move the compiled
    dist folder there and try running it. I did some tests on Ubuntu 22 and
    Debian 13.

    ## Comments

    One approach I considered is to use PyInstaller on all platforms for
    bundling dependencies, then pass the output to Briefcase as an [external
    app](https://briefcase.beeware.org/en/stable/how-to/building/external-apps/)
    so we have less platform differences to worry about. This worked well,
    especially on Windows, except that macOS universal binary support is
    [complicated](https://pyinstaller.org/en/stable/feature-notes.html#macos-multi-arch-support)
    (it requires all dependencies to have universal2 builds).

commit 087bbb2
Author: Abdo <abdo@abdnh.net>
Date:   Wed Mar 25 15:56:36 2026 +0300

    Customize Briefcase's Linux template (ankitects#4623)

    * Use our Linux template

    * Update template

    * Fix mypy error

    * Update template

    * Update template

commit 9d8e0d3
Author: Abdo <abdo@abdnh.net>
Date:   Wed Mar 25 13:32:41 2026 +0300

    Update Briefcase's Windows template (ankitects#4630)

commit 1e589ec
Author: Abdo <abdo@abdnh.net>
Date:   Wed Mar 25 13:32:13 2026 +0300

    List required Debian packages (ankitects#4627)

commit 40e19d3
Merge: 412464d ff610c6
Author: Andrew Sanchez <andrewsanchez@users.noreply.github.com>
Date:   Wed Mar 25 06:28:29 2026 -0400

    Merge branch 'briefcase' of https://github.com/ankitects/anki into release-action

commit 412464d
Author: Andrew Sanchez <andrewsanchez@users.noreply.github.com>
Date:   Wed Mar 25 05:47:53 2026 -0400

    Release action.

commit ff610c6
Merge: 3783457 2d44d4d
Author: Abdo <abdo@abdnh.net>
Date:   Tue Mar 24 19:26:14 2026 +0300

    Merge branch 'main' into briefcase

commit 3783457
Author: Abdo <abdo@abdnh.net>
Date:   Fri Mar 20 22:25:17 2026 +0300

    Tweak Briefcase app description

commit 1a6208a
Author: Abdo <abdo@abdnh.net>
Date:   Wed Mar 18 23:02:32 2026 +0300

    Fix Briefcase packaging for x86 Macs (ankitects#4618)

    * Use sys.executable

    * Refactor installer action into a BuildAction impl

    Also pass version as an arg

    * Use argparse

    * Build a universal macOS wheel

    * Move universal_wheel action to installer group

    So that the build-x64-mac script doesn't need to be run first every time the wheels group is run.

    * Add build-installer scripts

    * Fix mypy error

    * Replace cp39 tag

    We bumped the minimum Python version earlier

    * Fix Windows build

commit 051324f
Author: Abdo <abdo@abdnh.net>
Date:   Tue Mar 17 22:59:26 2026 +0300

    Set up Briefcase code signing and notarization (ankitects#4616)

    * Pass --identity to briefcase

    * Write Briefcase logs

    Can be found under out/installer/logs

commit d5a9721
Author: Abdo <abdo@abdnh.net>
Date:   Mon Mar 16 17:22:07 2026 +0300

    Customize Briefcase's MSI installer (ankitects#4609)

    * Move Briefcase app to subdir

    * Use our custom Windows template

    * Update Windows template

commit bd4df18
Author: Abdo <abdo@abdnh.net>
Date:   Wed Mar 11 16:16:49 2026 +0300

    Add Briefcase app permissions (ankitects#4601)

    * Add permissions

    * Add macOS entitlements

    * Add the audio-input entitlement

    permission.microphone maps to "com.apple.security.device.microphone" but the Briefcase docs claim otherwise.
    It doesn't seem to be required with the microphone entitlement in place, but adding it just in case.

    https://stackoverflow.com/a/57060745

commit 7d2901b
Author: Abdo <abdo@abdnh.net>
Date:   Tue Mar 10 21:43:34 2026 +0300

    Register file associations (ankitects#4598)

commit 0c92629
Author: Abdo <abdo@abdnh.net>
Date:   Tue Mar 10 19:06:14 2026 +0300

    Add Briefcase icons (ankitects#4596)

    * Add Briefcase icons

    * Generate scaled PNG icons

    * Generate CHANGELOG

    Required for .deb packages

commit d3adc4c
Author: Abdo <abdo@abdnh.net>
Date:   Fri Mar 6 20:38:50 2026 +0300

    Set up Briefcase (ankitects#4585)

    * Set up a Briefcase project

    * Replace pip-system-certs with truststore

    It doesn't play nicely with Briefcase and triggers RecursionError

    * Pass --adhoc-sign

    MacOS signing is deferred to a later PR.

    * Fix lint errors

    * Set `supportd = false` for mobile/web deployments

    * Fix `qt` extra

    * Use Briefcase 0.4.0

    Released yesterday
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants