PyOxidizer is a new utility designed to turn Python code into a single executable file that can be run on Windows, macOS, and Linux.
The Python programming language may bebut 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.
SEE: Six in-demand programming languages: getting started (free PDF) (TechRepublic)
"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," say 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 minimal cognitive effort from Python application maintainers".
If you're interested in PyOxidizer, check out the documentation, or if you want to find out more about Python in general, check out TechRepublic's guide to free resources for learning Python and this round-up of the best Python guides and code examples on GitHub.
- Getting started with Julia: A list of resources (free PDF) (TechRepublic)
- How to get started with Visual Studio 2019: The best new features whatever your programming language (TechRepublic)
- How to launch a successful developer career (Tech Pro Research)
- Microsoft's TypeScript programming language rising fast, almost makes top 10 (ZDNet)
- Top programming languages to learn in 2019? Developers name their favorites (ZDNet)
- Programming languages and developer career resources (TechRepublic on Flipboard)