Packaging Python CLIs and GUIs for air-gapped computers

Reto Trappitsch
July 10, 2024

Python Packaging | Reto Trappitsch | July 10, 2024

Why should we care?

  • Home-built instruments require home-built software
  • Python has a great ecosystem
    • Instrument control
    • Data analysis
  • But: Instrument computers are often air-gapped to run outdated software
  • We can't just pip install dependencies!
Python Packaging | Reto Trappitsch | July 10, 2024

The human aspect

  • Yes, dependency installation can be done offline but it's tricky
  • Updates require lots of manual work
  • The user needs to understand the python issues in detail
  • Overall, it's just not a good situation


Photo by Elliot Wilkinson on Unsplash
Python Packaging | Reto Trappitsch | July 10, 2024

Some possible solutions

Python Packaging | Reto Trappitsch | July 10, 2024

PyApp - A new solution to an old problem

  • A wrapper for python packages that bootstrap themselves at runtime
  • Package a project locally or directly from PyPi
  • Uses indygreg's highly-reproducable builds for standalone python
  • Example: Python project manager hatch is packaged via PyApp (both developped by Ofek Lev)

center

Python Packaging | Reto Trappitsch | July 10, 2024

And what does the user see?

center

Python Packaging | Reto Trappitsch | July 10, 2024

But you mentioned air-gapped machine in the title!

  • We can provide a standalone python build with all dependencies pre-installed!
  • PyApp environment variables allow us to skip installation via pip upon first run
  • Thus, no internet connection is required for the user!
  • My own notes on this: this GitHub gist
Python Packaging | Reto Trappitsch | July 10, 2024

boxing your apps

  • Configure your app inside pyproject.toml
  • Environment agnostic
  • Package with PyApp for CLIs or GUIs
  • Create installers for Linux, Windows, and MacOS
  • Runs on GitHub actions
  • NOT production ready!
Python Packaging | Reto Trappitsch | July 10, 2024

Questions?

  • Where can I try all of this?
  • You forgot [insert alternative here]!
    • Not actually a question ;)
    • Please let me know though!
  • Where can I find all the links and slides?
  • Can I test this? Yes please!
  • Can I help? Yes please, let's talk!
Python Packaging | Reto Trappitsch | July 10, 2024