Many have already heard about the
wheels / wheels ; I will not talk about them in detail - there were good articles on Habré. I will describe step by step one (obvious) way to use the wheels on the developer's machine.
Everyone who installed packages like numpy or scipy through pip knows that it’s a long time: compilation can take ten minutes and twenty or thirty minutes. You can set up an environment for compiling (well, at least under mac and linux, this is not so difficult), but it’s still fun to install such dependencies into each virtualenv. You can, of course, drink tea. Or virtualenv not use / use one common.
The wheels help solve the problem of a long installation. The point is this - the package is collected / compiled only once, then the installation is performed by unpacking the archive with the compiled files. So, in steps:
1. Register the path to the folder where the wheels will lie in
~/.pip/pip.conf
:
')
[global] wheel-dir=/Users/kmike/.wheels find-links=/Users/kmike/.wheels ; /Users/kmike/.wheels - pip
If there is no
~/.pip/pip.conf
, 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 from virtualenv, although not, without a difference. The wheels will roll into 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 version of python with the correct version of the package. If there is, then the installation will be almost instant. Now you can create for every sneeze virtualenvy and put scipy / numpy, etc. there.
TL; DR. You want to install a package - instead of “pip install foo” write for the first time “pip wheel foo; pip install foo ”, so that further the command“ pip install foo ”was executed instantly. Yeah, cap!
Remarks:
1. I wonder if it is possible to make this behavior default in pip (first cache the wheel, then install the package) to write one command instead of two.
2. An example with numpy is so-so, since for numpy == 1.8.1 under OS X wheels are immediately on pypi If you are using 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. For all this, more or less fresh pip is required.
4. Compared with the devpi method (described by the link at the beginning of the article) there are fewer possibilities, but everything is easier - a folder with files, three lines in the config, no servers.
5. It is assumed that pip install foo is already running. The problem of the lack of a FORTRAN compiler when building scipy will not be solved by the local wheel cache.
6. "pip wheel numpy scipy" may not work, because scipy requires numpy to be compiled. The correct sequence is “pip wheel numpy; pip install numpy; pip wheel scipy.
7. So that pip does not climb to the Internet at all, and put everything only from a local folder, you can use the pip install command to specify the option --no-index.
8. Installation of the wheels can be noticeably faster even for pure python packages.
9. All information is in the
documentation for pip.