Quick and handy wheel package format for Python applications
22 October 2013 Comments
Python packaging needs some help. A solution to at least some problems may be wheel - a new format for fast and efficient software installation and distribution. It's described in few PEPs and now it's starting to take shape. It was showcased recently on PyCon PL 2013.
There is nearly no wheels on pypi but we can use them locally to make local installations faster (handy for continuous integration systems and alike that build a project from scratch often).
You will need a recent version of pip and distribute (as described in the documentation). In old virtualenvs or systems execute:
pip install --upgrade pip distributeThen install wheel:
pip install wheel
Creating wheelsTo build wheels out of existing pypi packages you need to specify the packages and a local path for wheels:
pip wheel --wheel-dir=/wheel/folder PACKAGE_NAMETo install from local wheel folder just use:
pip install --use-wheel --no-index --find-links=/wheel/folder PACKAGE_NAMEIf you have your own local Python package you can build a wheel from setup.py:
python setup.py bdist_wheelIt works with distribute (but not with distutils). As a result you will get "whl" packages like those:
Django-1.5.4-py2.py3-none-any.whl Pillow-2.2.1-cp27-none-linux_x86_64.whlPillow is binary so it has the arch for which it have been built.
As an extra you also get "wheel" command that can operate on wheel packages (see "wheel help").
The speed boostDjango doesn't require compilation but it also doesn't install instantly. I've excluded download (pip install --no-install django) and measured install time (pip install --no-download django) on my computer:
Installing from wheel:
real 0m3.109s user 0m2.732s sys 0m0.994s
For Pillow compilation takes some time:
real 0m1.072s user 0m0.763s sys 0m0.308s
But with wheel it's a snap:
real 0m11.265s user 0m10.183s sys 0m1.178s
Even packages like Django can take advantage of the new package format. All binary packages will just install without the need of waiting for compilation to end. Nowadays it's mostly handy for build-testing (like continuous integration repeating tasks) and maybe deploying also.
real 0m0.170s user 0m0.135s sys 0m0.035s