About wheels

  • Tutorial
Many have already heard about wheels ; I will not tell in detail about them - on a habr there were good articles. I will describe step by step one (obvious) way to use the wheels on the developer's machine.

Everyone who has installed packages like numpy or scipy via pip knows that it takes a long time: compilation can take ten minutes, and twenty, and thirty. The compilation environment can be configured (well, at least for mac and linux it is not so difficult), but installing such dependencies in every virtualenv is still a pleasure. You can, of course, drink tea. Or virtual you do not use / use one common.

Wheels help solve the problem of long installation. The essence of this is that a package is compiled / compiled only once, then the installation is performed by unpacking the archive with the compiled files. So, the steps:

1. We write in the ~/.pip/pip.confpath to the folder where the wheels will lie:

; папка /Users/kmike/.wheels должна существовать - pip ее сам не создаст

If the file ~/.pip/pip.confdoes not exist, then it can be created. Under Windows, the correct file is different %HOME%\pip\pip.ini.

2. Install the wheel package, which is needed to assemble the wheels (it is no longer needed to install the wheels):

$ pip install wheel

3. We collect wheels for all of our often (and infrequently) used dependencies, for example

$ pip wheel numpy lxml Pillow

You can execute this command even from virtual, at least not, no difference. The wheels will roll out to the folder specified in pip.conf.

4. Thanks to our pip.conf, the “pip install foo” command will now check if there is already a ready wheel for the given python version with the right package version. If so, the installation will be almost instant. Now you can create virtual charts on each one and put scipy / numpy, etc.

TL; DR Do you want to install the package - instead of “pip install foo” write for the first time “pip wheel foo; pip install foo, so that the pip install foo command runs instantly. Yeah, cap!


1. I wonder if pip can make this behavior default (first, cache the wheel, then install the package) to write one command instead of two.
2. Example with numpy - so-so, because for numpy == 1.8.1 under OS X there are wheels immediately on pypi. If you use stock Python (and not, for example, compiled via brew), then “pip install numpy == 1.8.1” under the poppy should work so quickly - no compilation.
3. All this requires a more or less fresh pip.
4. Compared with the devpi method (described by the link at the beginning of the article), there are fewer options, but everything is simpler - a folder with files, three lines in the config, no servers.
5. It is assumed that pip install foo is already running. The local wheel cache will not solve the problem of the lack of a Fortran compiler when building scipy.
6. “pip wheel numpy scipy” may not work because scipy requires numpy installed to compile. The correct sequence is “pip wheel numpy; pip install numpy; pip wheel scipy. "
7. So that pip does not browse the Internet at all, but installs everything only from the local folder, you can specify the --no-index option to the pip install command.
8. Wheel mounting can be noticeably faster even for purely python packages.
9. All information is in the pip documentation .

Also popular now: