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).
Installing wheel
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 distribute
Then install wheel:
pip install wheel
Creating wheels
To 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_NAME
To install from local wheel folder just use:
pip install --use-wheel --no-index --find-links=/wheel/folder PACKAGE_NAME
If you have your own local Python package you can build a wheel from setup.py:
python setup.py bdist_wheel
It 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.whl
Pillow 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 boost
Django 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:real 0m3.109s
user 0m2.732s
sys 0m0.994s
real 0m1.072s
user 0m0.763s
sys 0m0.308s
real 0m11.265s
user 0m10.183s
sys 0m1.178s
real 0m0.170s
user 0m0.135s
sys 0m0.035s
RkBlog
Comment article