I was impressed with Tarek’s packaging talk at PyCon 2010, and I admire PEP 345 (Metadata for Python Software Packages 1.2) and PEP 376 (Database of Installed Python Distributions) which standardize a richer metadata format and show how distributions should be installed on disk. So naturally with all the hubbub about packaging in Python 3.3, I decided to try it to reap the benefits of a more standardized and predictable Python packaging experience.
I began by converting cryptacular, a password hashing package which has a simple C extension, to use setup.cfg. I downloaded the Python 3.3 source, struggled with the difference between setup.py and setup.cfg syntax, fixed the define_macros feature, stopped using the missing extras functionality, and several hours later I was able to generate my METADATA from setup.cfg. I rejoiced at my newfound freedom from the tyranny of arbitrary code execution during the build and install process.
It was a lot of work. The package is worse off than before, and it can’t be built or installed without patching the Python source code itself.
It was about that time that distutils-sig had a discussion about the need to include a generated setup.cfg from setup.cfg because setup.cfg wasn’t static enough. Wait, what?
Of course there is a different way to massively simplify the install process. It’s called built or binary packages. You never have to run setup.py because there is no setup.py. There is only METADATA aka PKG-INFO. Installation has two steps: ‘build package’; ‘install package’, and you can skip the first step, have someone else do it for you, do it on another machine, or install the build system from a binary package and let the build system handle the building. The build is still complicated, but installation is simple.
With the binary package strategy people who want to install use a simple, compatible installer, and people who want to package use whatever is convenient for them for as long as it meets their needs. No one has to rewrite setup.py for their own or the 20k+ other packages on PyPi unless a different build system does a better job.
Wheel is my attempt to benefit from the excellent distutils-sig work without having to fix the intractable distutils software itself. Like METADATA and .dist-info directories but unlike Extension(), it’s simple enough that there really could be alternate implementations; the simplest (but less than ideal) installer is nothing more than “unzip archive.whl” somewhere on sys.path.
If you’ve made it this far you probably wonder whether I’ve heard of eggs. Some comparisons:
I hope you will benefit from wheel.