kennethreitz/requests — pull request #2375 by sigmavirus24 (2014-12-09 02:58:42+00:00)
Title: WIP: Copy pip's import machinery wholesale

Fedora and Debian have both recently added symlinks to their distributions of requests so people can do `from requests.packages import urllib3` but they seem to still rewrite our import statements. So the following situation is possible:

- User registers adapter for custom scheme
- User does the following:

```python
from requests.packages.urllib3 import poolmanager

poolmanager.pool_classes_by_scheme['glance+https'] = HTTPSConectionPool
```

- When they do `s.get('glance+https://...')` they see a `KeyError` because the urllib3 we're using in requests is not the one they've imported (according to `sys.modules`).

Pip works around this with the copied machinery. The tests seem to work just fine for me. I still need to test this with our vendored packages removed and urllib3/chardet installed separately.

/cc @dstufft @eriolv @ralphbean