Use proxypypi to set up a transparent caching proxy to PyPI (https://pypy.python.org/) to:

When the proxy is asked about a package it doesn’t know it automatically goes off and fetches the file download list for the package, rewriting all references (PyPI and external) so they appear to be local. On request of one of those now-local package file references it performs a background fetch of the file contents and serves up the new file data to the pip request (thus keeping that request alive despite its very short timeout duration).

There’s a lot of PyPI-alike implementations and “proxy” servers out there. This proxy differs from almost all others (save devpi-server) in that it automatically relocates package download files from the Internet to your local server. It differs from devpi-server in that it has no external database requirement (just a filesystem is needed) making deployment much simpler (at least for me).

Usage

Setup of proxypypi requires:

“pip install proxypypi” cd to some directory you would like files to be cached in proxypypi run

There are some command-line arguments (see “proxypypi -h”) that allow some run-time behaviour control. Notably “-d” which can configure the directory to cache in.

Additionally the proxy may run in the background, in which case you need to supply three additional command-line arguments: “-P” (PID file), “-l” (log file) and “-o” (console output file) and use one of the daemon control commands instead of “run”. See “proxypypi -h” for the commands.

Once running you may perform pip installs using the proxy by including the proxy in the pip command line using the “-i” argument:

pip install -i http://proxy_host:proxy_port/simple/ package_to_install

Any packages not cached will be fetched into the cache and the install will continue as normal.