Post

python-build-standalone has exploded in popularity, with over 70M downloads all-time. But what is a "standalone" Python build? It wasn't obvious to me at first! Initially, I didn't understand what problem was being solved or why it mattered...

This is fine if you're building and installing Python on a single machine... but it's a problem if you want to pre-build Python and then distribute it to other machines, since those paths might be wrong!

Normally, CPython is also dynamically linked against a number of system libraries, which can cause trouble if the target machine doesn't have those libraries installed.

So, when you download Python from python.org on Linux, what you're actually downloading is an installer that builds Python from source on your machine. Similarly, when you install Python with pyenv, it too is building from source.

Building from source is desirable in some cases, but it also has its drawbacks...

0 reposts7 likes

First, it's much slower than downloading a pre-built binary, especially if you're building with optimizations enabled (i.e., PGO and LTO). In fact, pyenv builds with optimizations disabled by default, so you're leaving significant performance gains on the table.

The net effect is that on Linux and macOS, you can't "download a runnable Python binary" from... anywhere. Other than the python-build-standalone project.

(The notable exceptions here are (1) Linux distro package managers, which _can_ support, e.g., `apt install python3` and ship a binary, because IIUC they can rely on standardized system paths; and (2) the macOS installer on Python.org, which uses a Framework build.)