[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: About requests.packages.urllib3 in Debian



* Daniele Tricoli <eriol@mornie.org>, 2014-11-04, 23:35:
since requests 1.1.0-1 convenience copy of already packaged libraries are not shipped to follow Policy 4.13. (The package is tested at every rev but manually because tests need Internet connection.)

Due to #753578 I added a stub (technically I just used a symlink) to make import requests.packages.urllib3 works. It's used as import location by several projects since it is documented as import location:

   http://www.python-requests.org/en/latest/user/advanced/#example-specific-ssl-version

This lead to #767445 because Python import system doesn't know that urllib3 == requests.packages.urllib3 as described in detail here:

Maybe it'd be overkill, but it's possible to teach Python that urllib3 and requests.packages.urllib3 are the same thing. Adding something like this to the top of requests/__init__.py should do the trick:

import pkgutil
import sys
import urllib3

def _attach_namespace(package, where):
   for loader, name, ispkg in pkgutil.walk_packages(package.__path__, package.__name__ + '.'):
       try:
           module = __import__(name)
       except ImportError:
           continue # oh well
       sys.modules[where + '.' + name] = module

_attach_namespace(urllib3, 'requests.packages')
del _attach_namespace

--
Jakub Wilk


Reply to: