| 1 |
The Story of Wheel |
| 2 |
================== |
| 3 |
|
| 4 |
I was impressed with Tarek’s packaging talk at PyCon 2010, and I |
| 5 |
admire PEP 345 (Metadata for Python Software Packages 1.2) and PEP 376 |
| 6 |
(Database of Installed Python Distributions) which standardize a richer |
| 7 |
metadata format and show how distributions should be installed on disk. So |
| 8 |
naturally with all the hubbub about ``packaging`` in Python 3.3, I decided |
| 9 |
to try it to reap the benefits of a more standardized and predictable |
| 10 |
Python packaging experience. |
| 11 |
|
| 12 |
I began by converting ``cryptacular``, a password hashing package which |
| 13 |
has a simple C extension, to use ``setup.cfg``. I downloaded the Python 3.3 |
| 14 |
source, struggled with the difference between ``setup.py`` and ``setup.cfg`` |
| 15 |
syntax, fixed the ``define_macros`` feature, stopped using the missing |
| 16 |
``extras`` functionality, and several hours later I was able to generate my |
| 17 |
``METADATA`` from ``setup.cfg``. I rejoiced at my newfound freedom from the |
| 18 |
tyranny of arbitrary code execution during the build and install process. |
| 19 |
|
| 20 |
It was a lot of work. The package is worse off than before, and it can’t |
| 21 |
be built or installed without patching the Python source code itself. |
| 22 |
|
| 23 |
It was about that time that distutils-sig had a discussion about the |
| 24 |
need to include a generated ``setup.py`` from ``setup.cfg`` because |
| 25 |
``setup.cfg`` wasn’t static enough. Wait, what? |
| 26 |
|
| 27 |
Of course there is a different way to massively simplify the install |
| 28 |
process. It’s called built or binary packages. You never have to run |
| 29 |
``setup.py`` because there is no ``setup.py``. There is only METADATA aka |
| 30 |
PKG-INFO. Installation has two steps: ‘build package’; ‘install |
| 31 |
package’, and you can skip the first step, have someone else do it |
| 32 |
for you, do it on another machine, or install the build system from a |
| 33 |
binary package and let the build system handle the building. The build |
| 34 |
is still complicated, but installation is simple. |
| 35 |
|
| 36 |
With the binary package strategy people who want to install use a simple, |
| 37 |
compatible installer, and people who want to package use whatever is |
| 38 |
convenient for them for as long as it meets their needs. No one has |
| 39 |
to rewrite ``setup.py`` for their own or the 20k+ other packages on PyPI |
| 40 |
unless a different build system does a better job. |
| 41 |
|
| 42 |
Wheel is my attempt to benefit from the excellent distutils-sig work |
| 43 |
without having to fix the intractable ``distutils`` software itself. Like |
| 44 |
``METADATA`` and ``.dist-info`` directories but unlike Extension(), it’s |
| 45 |
simple enough that there really could be alternate implementations; the |
| 46 |
simplest (but less than ideal) installer is nothing more than “unzip |
| 47 |
archive.whl” somewhere on sys.path. |
| 48 |
|
| 49 |
If you’ve made it this far you probably wonder whether I’ve heard |
| 50 |
of eggs. Some comparisons: |
| 51 |
|
| 52 |
* Wheel is an installation format; egg is importable. Wheel archives do not need to include .pyc and are less tied to a specific Python version or implementation. Wheel can install (pure Python) packages built with previous versions of Python so you don’t always have to wait for the packager to catch up. |
| 53 |
|
| 54 |
* Wheel uses .dist-info directories; egg uses .egg-info. Wheel is compatible with the new world of Python ``packaging`` and the new concepts it brings. |
| 55 |
|
| 56 |
* Wheel has a richer file naming convention for today’s multi-implementation world. A single wheel archive can indicate its compatibility with a number of Python language versions and implementations, ABIs, and system architectures. Historically the ABI has been specific to a CPython release, but when we get a longer-term ABI, wheel will be ready. |
| 57 |
|
| 58 |
* Wheel is lossless. The first wheel implementation ``bdist_wheel`` always generates ``egg-info``, and then converts it to a ``.whl``. Later tools will allow for the conversion of existing eggs and bdist_wininst distributions. |
| 59 |
|
| 60 |
* Wheel is versioned. Every wheel file contains the version of the wheel specification and the implementation that packaged it. Hopefully the next migration can simply be to Wheel 2.0. |
| 61 |
|
| 62 |
I hope you will benefit from wheel. |