Updated Answer 19-Nov-15
According to the Pip documentation:
Starting with v6.0, pip provides an on by default cache which functions similarly to that of a web browser. While the cache is on by default and is designed do the right thing by default you can disable the cache and always access PyPI by utilizing the --no-cache-dir
option.
Therefore, the updated answer is to just use pip with its defaults if you want a download cache.
Original Answer
From the pip news, version 0.1.4:
Added support for an environmental variable $PIP_DOWNLOAD_CACHE which will cache package downloads, so future installations won’t require large downloads. Network access is still required, but just some downloads will be avoided when using this.
To take advantage of this, I've added the following to my ~/.bash_profile
:
export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache
or, if you are on a Mac:
export PIP_DOWNLOAD_CACHE=$HOME/Library/Caches/pip-downloads
Notes
- If a newer version of a package is detected, it will be downloaded and added to the
PIP_DOWNLOAD_CACHE
directory. For instance, I now have quite a few Django packages.
- This doesn't remove the need for network access, as stated in the pip news, so it's not the answer for creating new
virtualenvs
on the airplane, but it's still great.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…