Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is my solution using pip, managing even installation of binary packages and usable on both, linux and Windows. And as requested, it will limit download from PyPi to the mininum, and as extra bonus, on Linux, it allows to speed up repeated installation of packages usually requiring compilation to a fraction of a second.</p> <p>Setup takes few steps, but I thing, it is worth to do.</p> <h1>Create pip config file</h1> <p>Create pip configuration file (on linux: ~/.pip/pip.conf, on Windows %HOME%\pip\pip.ini)</p> <p>My one has this content:</p> <pre><code>[global] download-cache = /home/javl/.pip/cache find-links = /home/javl/.pip/packages [install] use-wheel = yes [wheel] wheel-dir = /home/javl/.pip/packages </code></pre> <h1>Populating <code>cache</code> dir - goes automatically</h1> <p>The <code>cache</code> dir will get cached version of data downloaded from pypi each time, pip attempts to get some package from pypi. It is easy to get it there (no special care needed), but note, that from pip point of view, these are just cashed data downloaded from PyPi, not packages, so in case you use an option <code>--no-index</code>, it will not work.</p> <h1><code>pip install --download</code> to populate <code>packages</code> dir</h1> <p>The <code>packages</code> dir is place to put real package files to. E.g. for my favorite package <code>plac</code>, I would do:</p> <p>$ pip install --download ~/.pip/packages plac</p> <p>and the plac package file would appeare in that dir. You may even use <code>-r requirements.txt</code> file to do this for multiple packages at once.</p> <p>These packages are used even whith <code>$ pip install --no-index &lt;something&gt;</code>.</p> <h1>Prevent repeated compilation of the same package on Linux</h1> <p>E.g. <code>lxml</code> package requires compliation, and download and compile may take from 45 seconds to minutes. Using wheel format, you may save here a lot.</p> <p>Install <code>wheel</code> tool, if you do not have it yet:</p> <pre><code>$ pip install wheel </code></pre> <p>Create the wheel for <code>lxml</code> (assuming, you have managed to install <code>lxml</code> in past - it requires some libs in the system to be installed):</p> <pre><code>$ pip wheel lxml </code></pre> <p>This goes over download, compile, but finally results in lxml <code>whl</code> file being in <code>packgages</code> dir.</p> <p>Since then</p> <pre><code>$ pip install lxml </code></pre> <p>or even faster</p> <pre><code>$ pip install --no-index lxml </code></pre> <p>will take fraction of a second, as it uses wheel formatted package.</p> <h1>Prepare wheel package from Window setup exe package</h1> <p>(note: this can be prepared even on Linux machine, there is no compilation, only some repacking from exe file into <code>whl</code>.)</p> <ol> <li><p>download the exe form of the package from pypi, e.g:</p> <p>$ wget <a href="https://pypi.python.org/packages/2.7/l/lxml/lxml-3.2.3.win32-py2.7.exe#md5=14ab978b7f0a3382719b65a1ca938d33" rel="noreferrer">https://pypi.python.org/packages/2.7/l/lxml/lxml-3.2.3.win32-py2.7.exe#md5=14ab978b7f0a3382719b65a1ca938d33</a> $ dir lxml-3.2.3.win32-py2.7.exe</p></li> <li><p>convert it to <code>whl</code></p> <p>$ wheel convert lxml-3.2.3.win32-py2.7.exe $ dir lxml-3.2.3.win32-py2.7.exe lxml-3.2.3-cp27-none-win32.whl</p></li> <li><p>Test it:</p> <p>$ pip install lxml</p></li> </ol> <p>or</p> <pre><code>$ pip install --no-index lxml </code></pre> <p>shall be very quick.</p> <p>Note, that <code>wheel convert</code> can do exactly the same conversion for egg formatted packages.</p> <h1>Let <code>easy_install</code> and <code>setup.py install</code> reuse your <code>packages</code> dir</h1> <p><code>easy_install</code> and <code>$ python setup.py install</code> do not seem to offer download cache, but allow to use packages we have in our <code>packages</code> dir.</p> <p>To do so, edit config file for these two tools:</p> <p>On Linux: <code>$HOME/.pydistutils.cfg</code></p> <p>On Windows: <code>%HOME%\pydistutils.cfg</code></p> <p>In my case I have here in <code>/home/javl/.pydistutils.cfg</code>:</p> <pre><code>[easy_install] find_links = /home/javl/.pip/packages </code></pre> <p>This config may help even some cases of <code>pip install</code> calls, when pip attempts to install a package, declaring dependency on other ones. As it delegates this task to <code>setup.py</code> call, without the <code>.pydistutils.cfg</code> config it would download the file from PyPi.</p> <p>Unfortunatelly, wheel format is not supported in this case (as far as I am aware of).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload