Comparisons to Other Tools

What makes PyOxidizer different from other Python packaging and distribution tools? Read on to find out!

PyInstaller

PyInstaller - like PyOxidizer - can produce a self-contained executable file containing your application. However, at run-time, PyInstaller will extract Python source/bytecode files to a temporary directory then import modules from the filesystem. PyOxidizer typically skips this step and loads modules directly from memory using zero-copy. This makes PyOxidizer executables significantly faster to start.

py2exe

py2exe is a tool for converting Python scripts into Windows programs, able to run without requiring an installation.

The goals of py2exe and PyOxidizer are conceptually very similar.

One major difference between the two is that py2exe works on just Windows whereas PyOxidizer works on multiple platforms.

Another significant difference is that py2exe distributes a copy of Python and your Python resources in a more traditional manner: as a pythonXY.dll and a library.zip file containing compiled Python bytecode. PyOxidizer is able to compile the Python interpreter and your Python resources directly into the .exe so there can be as little as a single file providing your application.

Also, the approach to packaging that py2exe and PyOxidizer take is substantially different. py2exe embeds itself into setup.py as a distutils extension. PyOxidizer wants to exist at a higher level and interact with the output of setup.py rather than get involved in the convoluted mess of distutils internals. This enables PyOxidizer to provide value beyond what setup.py/distutils can provide.

Shiv

Shiv is a packager for zip file based Python applications. The Python interpreter has built-in support for running self-contained Python applications that are distributed as zip files.

Shiv requires the target system to have a Python executable and for the target to support shebangs in executable files. This is acceptable for controlled *NIX environments. It isn’t acceptable for Windows (which doesn’t support shebangs) nor for environments where you can’t guarantee an appropriate Python executable is available.

Also, by distributing our own Python interpreter with the application, PyOxidizer has stronger guarantees about the run-time environment. For example, your application can aggressively target the latest Python version. Another benefit of distributing your own Python interpreter is you can run a Python interpreter with various optimizations, such as profile-guided optimization (PGO) and link-time optimization (LTO). You can also easily configure custom memory allocators or tweak memory allocators for optimal performance.

PEX

PEX is a packager for zip file based Python applications. For purposes of comparison, PEX and Shiv have the same properties. See Shiv for this comparison.

XAR

XAR requires the use of SquashFS. SquashFS requires Linux.

PyOxidizer is a target native executable and doesn’t require any special filesystems or other properties to run.

Docker / Running a Container

It is increasingly popular to distribute applications as self-contained container environments. e.g. Docker images. This distribution mechanism is effective for Linux users.

PyOxidizer will almost certainly produce a smaller distribution than container-based applications. This is because many container-based applications contain a lot of extra content that isn’t needed by the processes within.

PyOxidizer also doesn’t require a container execution environment. Not every user has the capability to run certain container formats. However, nearly every user can run an executable.

At run time, PyOxidizer executes a native binary and doesn’t have to go through any additional execution layers. Contrast this with Docker, which uses HTTP requests to create containers, set up temporary filesystems and networks for the container, etc. Spawning a process in a new Docker container can take hundreds of milliseconds or more. This overhead can be prohibitive for low latency applications like CLI tools. This overhead does not exist for PyOxidizer executables.

Nuitka

Nuitka can compile Python programs to single executables. And the emphasis is on compile: Nuitka actually converts Python to C and compiles that. Nuitka is effectively an alternate Python interpreter.

Nuitka is a cool project and purports to produce significant speed-ups compared to CPython!

Since Nuitka is effectively a new Python interpreter, there are risks to running Python in this environment. Some code has dependencies on CPython behaviors. There may be subtle bugs are lacking features from Nuitka. However, Nuitka supposedly supports every Python construct, so many applications should just work.

Given the performance benefits of Nuitka, it is a compelling alternative to PyOxidizer.

PyRun

PyRun can produce single file executables. The author isn’t sure how it works. PyRun doesn’t appear to support modern Python versions. And it appears to require shared libraries (like bzip2) on the target system. PyOxidizer supports the latest Python and doesn’t require shared libraries that aren’t in nearly every environment.

pynsist

pynsist is a tool for building Windows installers for Python applications. pynsist is very similar in spirit to PyOxidizer.

A major difference between the projects is that pynsist focuses on solving the application distribution problem on Windows where PyOxidizer aims to solve larger problems around Python application distribution, such as performance optimization (via loading Python modules from memory instead of the filesystem).

PyOxidizer has yet to invest significantly into making producing distributable artifacts (such as Windows installers) simple, so pynsist still has an advantage over PyOxidizer here.