Skip to content

Python Wheels

This week, I tried to install a Python package called mlc-llm for a side project, but its pip install pipeline was broken. The webpage that hosts its wheels was down, so pip kept hitting an endpoint that returned a 404. To work around it, I went to mlc-llm’s GitHub repo, found the release artifacts, and manually downloaded and installed the wheels.

I don’t remember the last time pip install failed in a way that forced me to do that, and honestly, before this, I didn’t really know what wheels were. In this article, I will explain what they are, and how they make installing Python packages fast and reliable.

  • Credit: I learned about Python wheels from this post, and I’ll be using the same examples.

PyPI (Python Package Index) is the public registry where Python packages are published. pip is the installer that downloads those packages (usually from PyPI) and installs them into your current environment.

But what exactly is getting downloaded? Depending on the package, pip might download a source distribution (sdist) or a wheel (whl). Let’s unpack what those are, and how they’re different.

Let’s start with source distributions. An sdist contains the package’s source code (plus the build/config files needed to install it). If the project includes any native code, that source has to be built on your machine to match your OS and architecture before it can be installed.

Let’s look at an example. uWSGI v2.0 is a package where pip installs from an sdist.

Terminal window
$ python -m pip install 'uwsgi==2.0.*'
Collecting uwsgi==2.0.*
Downloading uwsgi-2.0.18.tar.gz (801 kB)
|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 801 kB 1.1 MB/s
Building wheels for collected packages: uwsgi
Building wheel for uwsgi (setup.py) ... done
Created wheel for uwsgi ... uWSGI-2.0.18-cp38-cp38-macosx_10_15_x86_64.whl
Stored in directory: /private/var/folders/jc/8_hqsz0x1tdbp05 ...
Successfully built uwsgi
Installing collected packages: uwsgi
Successfully installed uwsgi-2.0.18

In the pip install logs, we see that a .tar.gz file is first installed (that’s the sdist). Then pip builds a macOS wheel on my machine, and installs that result. So when pip installs from an sdist, the flow is basically: download source β†’ build locally β†’ install.

But let’s take a step back: what does it actually mean to β€œbuild source into a macOS wheel”?

To see why wheels matter, consider a package that isn’t pure Python, one that includes extension modules. An extension module is something you import from Python, but its implementation is compiled native code (often C/C++/Rust) rather than a .py. In other words, it’s a Python wrapper around fast, low-level code.

A .whl file is really just a structured archive (basically a .zip). For a pure-Python project, it contains the .py files plus some metadata. But if the package includes extension modules, the wheel also bundles the compiled extension binaries. That’s why wheels are platform-specific: compiled code has to match a particular OS and CPU architecture. So now we know what’s happening when pip installs an sdist and builds a macOS wheel locally.

This download source β†’ build locally β†’ install pipeline has a few downsides. Even when pip handles the build automatically, it can be slow (compiling native code takes time) and fragile (it can fail if your machine isn’t set up as a build environment). Many projects rely on external tooling (compilers, build systems like CMake/Meson/Ninja, and system libraries/headers) that might not be installed or configured correctly. When that happens, pip install turns into a build debugging session instead of a one-line install.

Today, many packages publish pre-built wheels to PyPI, so pip install can download the wheel that matches your platform instead of building from source. Wheel filenames follow a standard naming scheme that encodes compatibility (Python version/ABI and the target OS/architecture), so pip can choose the right one automatically.

{dist}-{version}(-{build})?-{python}-{abi}-{platform}.whl

There are also a few special tags worth calling out. A py3-none-any wheel is a pure-Python wheel: it has no compiled extensions (none), and it can run on any OS and architecture (any). That makes it the most portable kind of wheel.

On Linux, you’ll often see manylinux wheels. These are built against a conservative baseline so the same wheel can run across a wide range of Linux distributions, including older ones.

So if we look at the pip install logs here, there’s no β€œbuild” stage. pip just downloads a matching wheel and installs it.

Terminal window
$ python -m pip install 'chardet==3.*'
Collecting chardet
Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 133 kB 1.5 MB/s
Installing collected packages: chardet
Successfully installed chardet-3.0.4

In this post, I broke down the difference between source distributions and wheels, and why wheels usually make pip install fast and reliable. Hopefully I won’t encounter another situation like I did with mlc-llm, but understanding how wheels work makes these installation issues a lot less mysterious.