alphagov/ghtools — pull request #7 by mattbostock (2014-11-24 11:53:50+00:00)
Title: Upgrade requests library to version 2.4.3

Upgrade the `requests` library to the latest version, 2.4.3.

This is to prevent a conflict on Ubuntu Trusty between system Python
libraries and Pip libraries.

Specifically, it appears that `requests.compat` was referring to the
`IncompleteRead` module which was exported by the `http.client` library
[1], which has since been removed.

This was causing the following Puppet error on our ci-slave-4 box in Vagrant
using Ubuntu Trusty:

==> ci-slave-4: Error: Could not prefetch package provider 'pip': [nil, nil, [(provider=pip)], nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]

When I tried to run `pip` on the Vagrant box, I got the following error:

vagrant@ci-slave-4:~$ pip
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2363, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
vagrant@ci-slave-4:~$

This was occurring because installing ghtools caused version 1.1.0 of
the `requests` library to be installed to
`/usr/local/lib/python2.7/dist-packages`. It would appear that version
1.1.0 of `requests` is incompatible with the `http` module supplied by
the system python under Ubuntu Trusty.

For more context, please see this bug report (though the bug is not in
python-pip):
https://bugs.launchpad.net/ubuntu/+source/python-pip/+bug/1306991

[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=766419#23