The Python programming language may be hugely popular among developers but sharing a Python app with your average computer user is still tricky.
The problem of not being able to simply package up Python apps was singled out as a threat to the future of the language by BeeWare co-founder Russell Keith-Magee at this year's Python Language Summit.
"Why would I want to learn Python if I can't get a clear answer for that basic question of how I give my code to my non-programmer friends," he said.
To try to make it easier to share an app and have it work on any desktop PC, Mozilla developer Gregory Szorc has released PyOxidizer, a free utility which is designed to turn Python code into a single executable file that can be run on Windows, macOS, and Linux.
Szorc says your average user shouldn't have to worry about whether an application will run without downloading the correct software libraries.
"Most end-users don't care about the technical implementation, they just want to get stuff done," he writes, describing the Python app distribution problem as an "existential threat".
"Unless your target user is a Python developer, they shouldn't need to know anything about Python packaging, Python itself, or even the existence of Python in order to use your application."
The executable file generated by PyOxidizer contains a fully featured Python interpreter, its extensions, standard library, and an application's modules and resources, with Szorc saying he has minimized OS-specific dependencies.
"On Linux, it is possible to build a fully statically linked executable. You can drop this executable into a chroot or container where it is the only file and it will just work. On macOS and Windows, the only library dependencies are on always-present or extremely common libraries."
Szorc stresses that this first release of PyOxidizer is focused on essential features and "comes nowhere close" to solving the "Python application distribution problem".
"In today's release, PyOxidizer is good at producing executables embedding Python. It doesn't yet venture too far into the distribution part of the problem (I want it to be trivial to produce MSI installers, DMG images, deb/rpm packages, etc)," he writes, adding that solving distribution of apps to mobile platforms is also a future goal.
Despite PyOxidizer being a work in progress, Szorc says PyOxidizer executables should already be faster to start than a Python executable and capable of addressing some shortcomings of other Python packaging and distribution tools, such as PyInstaller and py2exe.
He suggests that large Python applications such as Dropbox and Kodi could be made smaller and simpler by using PyOxidizer to produce self-contained executables.
"By enabling support for self-contained, single-file Python applications, PyOxidizer opens exciting new doors for Python," says Szorc, giving the example of being able to use the IT orchestration software Ansible to configure remote computers without having to first install a Python interpreter on those machines.
Ultimately, Szorc says, "I want PyOxidizer to provide a Python application packaging and distribution experience that just works with a minimal cognitive effort from Python application maintainers".