packages.py 695 B

12345678910111213141516
  1. import sys
  2. # This code exists for backwards compatibility reasons.
  3. # I don't like it either. Just look the other way. :)
  4. for package in ('urllib3', 'idna', 'chardet'):
  5. vendored_package = "pip._vendor." + package
  6. locals()[package] = __import__(vendored_package)
  7. # This traversal is apparently necessary such that the identities are
  8. # preserved (requests.packages.urllib3.* is urllib3.*)
  9. for mod in list(sys.modules):
  10. if mod == vendored_package or mod.startswith(vendored_package + '.'):
  11. unprefixed_mod = mod[len("pip._vendor."):]
  12. sys.modules['pip._vendor.requests.packages.' + unprefixed_mod] = sys.modules[mod]
  13. # Kinda cool, though, right?