Custom Search

Saturday, November 29, 2014

Python pip install from local cache

1)
Enable download_cache for pip.

Create a configuration file named ~/.pip/pip.conf, and add the following contents:
[global]
download_cache = ~/.cache/pip

OR

In one commeand
#printf '[global]\ndownload_cache = ~/.cache/pip\n' >> ~/.pip/pip.conf



2)
Install a package
#pip install six

* Add the package "six" to cache and install

3)
Check the files in the cache
#ls -lsh ~/.cache/pip/

4)
Install the same package again and you can see that it takes from the cache
#pip install six

* Get the package "six" from cache and install

5)
You can also manually add packages to pip cache

a)
Download the package https://pypi.python.org/packages/source/B/Babel/Babel-1.3.tar.gz#md5=5264ceb02717843cbc9ffce8e6e06bdb

b)
Copy the downloaded "Babel-1.3.tar.gz" file to "~/.cache/pip/" folder and rename ot complete url path.
#mv Babel-1.3.tar.gz https://pypi.python.org/packages/source/B/Babel/Babel-1.3.tar.gz

c)

Modify the name
Replace "/" with %2F
Repalce ":" with %3A
Like : https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2FB%2FBabel%2FBabel-1.3.tar.gz

d)
Create another file with above name and extension ".content-type" and add the content "application/octet-stream".

Example:
#vim https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fm%2Fmock%2Fmock-1.0.1.tar.gz.content-type

application/octet-stream



No comments:

Post a Comment