DEV Community

Cover image for Shipping a Python desktop app to people who have never installed Python
Vihan-2008
Vihan-2008

Posted on

Shipping a Python desktop app to people who have never installed Python

By Vihan, who makes JARVIS (https://github.com/Vihan-2008/jarvis). Written with help from an AI assistant.

JARVIS is a desktop assistant written in Python, using only the standard library. For a long time, installing it meant "first install Python 3.11". For anyone who isn't a developer, that's where it ended. I set myself one test: someone who has never used GitHub opens the project page, picks the right download, installs JARVIS and gives it one command, without a terminal and without asking me. Here's what that took.

  1. Carry your own Python python-build-standalone publishes relocatable CPython builds for every platform. The Windows build is 22 MB compressed, each Mac one about 25 MB. The build scripts download a pinned release, check it against a SHA-256 written in the repository (installer/runtime.py), and put it in the package. The installer unpacks it beside the app, not on the system, so nothing else on the computer changes. It unpacks only when the version changed, into a new folder that is then swapped in, so an update never leaves a half-replaced interpreter behind.

One catch I nearly shipped: the in-app updater runs on that same bundled Python, from inside the install folder. The installer stops any JARVIS process running from that folder before replacing files, so it would have stopped the updater halfway through an update. It now skips its own ancestors.

  1. Windows: an installer that asks nothing
    JARVIS-Setup.exe is IExpress (built into Windows) wrapping a zip and a small script. It checks free space, stops a running copy, installs per user (no admin), registers under Settings > Apps, and opens JARVIS. Uninstalling offers to send data and notes to the Recycle Bin rather than deleting them.

  2. macOS: app translocation
    The Mac download used to show Install JARVIS.command, which opens Terminal. I replaced it with a small AppleScript app made by osacompile. The first version kept the installer's files beside the app, and that would have broken for every user. An app that is quarantined and opened where it was downloaded is run by macOS from a hidden, read-only copy of the app alone ("app translocation"), so anything beside it is invisible. The fix: everything the installer needs lives inside the app bundle (Contents/Resources), and the bundle is signed again (ad hoc) after the files go in, because a bundle whose contents don't match its signature is reported as "damaged".

  3. Test the thing people download
    The tests used to install from the source tree. Now CI builds the real packages, installs them on fresh GitHub runners as a new user would (on Windows by running Setup.exe, on the Mac by running the installer app's own script), opens the app, sends the first command ("open calculator") through the same API the window uses, checks that the program is running, and uninstalls it, checking that the notes went where they were told to.

What's still missing
Code signing. Without an Apple Developer membership and a Windows certificate, Gatekeeper and SmartScreen warn once. The download page explains what to click, but it's the last bit of friction left.

Top comments (0)