Computerworld

PyOxidizer uses Rust to make Python executables

A new project written in Rust aims to make it easier to distribute Python applications as standalone binaries

A new project, written in Rust, aims to make it easier to package and distribute a Python application as a standalone binary executable—something that has long been a pain point for Python developers.

PyOxidizer, according to its GitHub README, is “a collection of Rust crates that facilitate building libraries and binaries containing Python interpreters.” With PyOxidizer, its developers claim, it’s possible to build an executable for a Python app that embeds a Python interpreter, with no other runtime dependencies.

PyOxidizer requires an installation of Rust 1.31 or better, and packages only apps written with Python 3.7. To use PyOxidizer, the developer creates a TOML file that describes how to embed a given Python app, then builds and runs PyOxidizer with an environment variable pointing to that TOML file.

PyOxidizer stands apart from other packaging solutions in using a custom build of the Python interpreter that is designed to be statically linked and embedded into another program. Other solutions, like PyInstaller, redistribute the existing stock CPython .DLL—convenient and compatible, but not very flexible. PyOxidizer also packs the bytecode for the Python app into the executable image and loads it directly from memory (fast), rather than from the file system (slower).

Like PyInstaller, though, PyOxidizer does not perform any optimizations on the Python code. Another project, Nuitka, not only compiles Python apps to standalone executables, but also tries to apply performance optimizations to the compiled code. However, Nuitka is still considered a beta-level project, and a great many of the projected performance improvements aren’t available yet.

PyOxidizer itself is still a very early-stage project. It can generate only Linux binaries because one of the upstream projects it depends on, the embeddable version of CPython, is currently available only in Linux builds.