Friday, June 24, 2016

configure pip on windows to use differrent repositories

***information***
local repository :  simple.pypi.repo
how to install local repository: http://www.atechnote.com/2016/05/setup-your-own-python-pypi-repository.html


1- we can tell pip to use different repository directly on command line by using option -i and --trusted-host,.

C:\Python27\Scripts>pip.exe install -i http://simple.pypi.repo/simple --trusted-
host simple.pypi.repo yolk
Collecting yolk
  Downloading http://simple.pypi.repo/packages/2b/c0/73510e50668b70f3fad25328c58
d7a29a300a2e452058dfdcb7c7538af7b/yolk-0.4.3.tar.gz (86kB)
    100% |################################| 90kB 2.6MB/s
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\pytho
n27\lib\site-packages (from yolk)
Installing collected packages: yolk
  Running setup.py install for yolk
Successfully installed yolk-0.4.3




2- but to use like above it will be a chores, because have to type the repository every time we install a package so we can configure those options in configuration file %APPDATA%\pip\pip.ini with the following content:

 [global]
index-url = http://simple.pypi.repo/simple
trusted-host = simple.pypi.repo



- now we can install by typing only install and package name like below

C:\Python27\Scripts>pip install django
Collecting django
  Downloading http://simple.pypi.repo/packages/cb/97/081df31f2a3850988b92ad4464e
95f9e4b257aa5a34e120bca89c260de96/Django-1.9.6-py2.py3-none-any.whl (6.6MB)
    100% |################################| 6.6MB 2.6MB/s
Installing collected packages: django
Successfully installed django-1.9.6


No comments:

Post a Comment