Wednesday, May 25, 2016

how to make pip case sensitive

pip is case insensitive, so if you setup your own python modules repository, pip will not work with most of the packages.

link below is how to setup squid to correct bandersnatch path, when we run the repository
http://www.atechnote.com/2016/05/use-squid-redirectprogram-to-correct.html


1- install intelligent recursive search/replace utility rpl
$ sudo apt-get install rpl

2- cd pip directory
$ cd /usr/lib/python2.7/dist-packages/pip

3- remove lower() from every single in that directory
$ sudo rpl -s -a ".lower()" "" *
Really DELETE all occurences of .lower() (case sensitive)? (Y/[N]) Y
Simulating replacement of ".lower()" with "" (case sensitive) (partial words matched)
The files listed below would be modified in a replace operation.
  /usr/lib/python2.7/dist-packages/pip/baseparser.py
  /usr/lib/python2.7/dist-packages/pip/download.py
  /usr/lib/python2.7/dist-packages/pip/index.py
  /usr/lib/python2.7/dist-packages/pip/__init__.py
  /usr/lib/python2.7/dist-packages/pip/wheel.py

A Total of 22 matches found in 24 files searched.
None replaced (simulation mode).


$ sudo rpl -s -a ".lower()" "" */*
Really DELETE all occurences of .lower() (case sensitive)? (Y/[N]) Y
Simulating replacement of ".lower()" with "" (case sensitive) (partial words matched)
The files listed below would be modified in a replace operation.
  /usr/lib/python2.7/dist-packages/pip/commands/__init__.py
  /usr/lib/python2.7/dist-packages/pip/commands/list.py
  /usr/lib/python2.7/dist-packages/pip/commands/show.py
  /usr/lib/python2.7/dist-packages/pip/operations/freeze.py
  /usr/lib/python2.7/dist-packages/pip/req/req_install.py
  /usr/lib/python2.7/dist-packages/pip/req/req_set.py
  /usr/lib/python2.7/dist-packages/pip/utils/__init__.py
  /usr/lib/python2.7/dist-packages/pip/vcs/bazaar.py
  /usr/lib/python2.7/dist-packages/pip/vcs/git.py
  /usr/lib/python2.7/dist-packages/pip/vcs/__init__.py
  /usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py
  /usr/lib/python2.7/dist-packages/pip/vcs/subversion.py

A Total of 30 matches found in 82 files searched.
None replaced (simulation mode).


Now pip will be case sensitive


-----
$ pip -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)

No comments:

Post a Comment