Wheel files in python
20-05-2025
Introduced in PEP 427:
What are wheel files:
- built distribution which replaces the egg format (ready-to-install)
{dist}-{version}(-{build})?-{python}-{abi}-{platform}.whl
- example =
cryptography-2.9.2-cp35-abi3-macosx_10_9_x86_64.whl
- version = https://peps.python.org/pep-0440/
- python = https://peps.python.org/pep-0425/
- abi = https://docs.python.org/3/c-api/stable.html
- platform = OS / OS tools needed for compilation / instruction set architecture
- example =
- ZIP-format archive,
.whl
file extension, containing a single distribution, may be unpacked directly intosite-packages
Benefits:
- smaller in size
- allows for faster installation for pure python and native C extension packages
- avoids arbitrary code execution for installation
- everything is run inside
setup.py
when usingsdist
- everything is run inside
- more consistent installs across platforms and machines
- does not require a compiler for C extensions
- pip generates
.pyc
files in the wheel that match the right interpreter
Types of wheels:
- universal wheel (python 2 AND python 3 AND any OS)
- pure-python wheel (python 2 OR python 3)
- platform wheel ([python 2 or python 3] AND platform)
Tools to build wheels for all:
- https://github.com/pypa/cibuildwheel
- https://github.com/multi-build/multibuild
- https://github.com/pypa/auditwheel - bundle external libraries into wheels