Why it’s so laborious to create stand-alone Python apps


  • Set up it into an current Python interpreter. That is the most typical situation, however it requires establishing a duplicate of the interpreter. At greatest, this implies a wholly separate step, one fraught with complexity if Python variations exist already on the system. That is additionally the situation individuals need to keep away from within the first place, as a result of they need to make their app as simple to redistibute as potential.
  • Bundle the interpreter with this system and its dependencies. That is the strategy taken by tasks like PyInstaller and Nuitka. The downsides are that the deliverables are usually fairly massive, and creating them requires studying the quirks of those tasks. However they do work.
  • Use a system like Docker to bundle this system. Docker containers introduce their very own world of trade-offs. On the one hand, you get completely the whole lot it’s worthwhile to run this system, together with any system-level dependencies. Alternatively, the ensuing container could be positively hefty. And, after all, utilizing Docker means adopting a further software program ecosystem.

Among the newer options to the issue attempt to clear up one explicit ache level or one other, as a solution to make the entire difficulty much less unpalatable. As an example, PyApp makes use of Rust to construct a self-extracting binary that installs the wanted Python distribution, your app, and all its dependencies. It has two huge drawbacks: you want the Rust compiler to construct it to your challenge, and your challenge have to be an installable package deal that makes use of the pyproject.toml commonplace. The primary of those necessities is more likely to be the bigger hurdle; most Python tasks want a pyproject.toml of some form at this level.

One other answer is one I wrote myself: pydeploy. It additionally requires the challenge in query be installable through pip set up. In any other case, pydeploy wants nothing greater than Python’s commonplace library to generate a self-contained deliverable with the Python runtime included. Its huge disadvantage proper now’s that it solely works for Microsoft Home windows, however in principle it may work on any working system.

Possibly sometime

All of the current main adjustments being proposed for Python, akin to the brand new native JIT and full concurrency or multithreading, are supposed to improve Python’s conduct as a dynamic language. Any proposals designed to alter that dynamism primarily would imply creating a brand new language with totally different expectations about its conduct.