Skip to content

Commit 0dfc6e7

Browse files
committed
Merge pull request #387 from canibanoglu/pip-caching
Added instructions to set up pip for caching packages
2 parents e6b8ba3 + 78d5318 commit 0dfc6e7

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

docs/starting/pip-virtualenv.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,47 @@ After saving the changes and sourcing your ``~/.bashrc`` file you can now instal
8282
packages globally by running ``gpip install``. You can change the name of the
8383
function to anything you like, just keep in mind that you will have to use that
8484
name when trying to install packages globally with pip.
85+
86+
Caching packages for future use
87+
-------------------------------
88+
89+
Every developer has preferred libraries and when you are working on a lot of
90+
different projects, you are bound to have some overlap between the libraries that
91+
you use. For example, you may be using the ``requests`` library in a lot of different
92+
projects.
93+
94+
It is surely unnecessary to re-download the same packages/libraries each time you
95+
start working on a new project (and in a new virtual environmen as a result).
96+
Fortunately, you can configure pip in such a way that it tries to reuse already
97+
installed packages.
98+
99+
On UNIX systems, you can add the following line to your ``.bashrc`` or ``.bash_profile``
100+
file.
101+
102+
.. code-block:: console
103+
104+
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
105+
106+
You can set the path to anywhere you like (as long as you have write
107+
access). After adding this line, ``source`` your ``.bashrc`` (or ``.bash_profile``)
108+
file and you will be all set.
109+
110+
Another way of doing the same configuration is via the ``pip.conf`` or ``pip.ini``
111+
files, depending on your system. If you are on Windows, you can add the following
112+
line to your ``pip.ini`` file under ``[global]`` settings:
113+
114+
.. code-block:: console
115+
116+
download-cache = %HOME%\pip\cache
117+
118+
Similarly, on UNIX systems you should simply add the following line to your
119+
``pip.conf`` file under ``[global]`` settings:
120+
121+
.. code-block:: console
122+
123+
download-cache = $HOME/.pip/cache
124+
125+
Even though you can use any path you like to store your cache, it is recommended
126+
that you create a new folder *in* the folder where your ``pip.conf`` or ``pip.ini``
127+
file lives. If you don't trust yourself with all of this path voodoo, just use
128+
the values provided here and you will be fine.

0 commit comments

Comments
 (0)