Package: python-requests Version: 2.7.0-2 Severity: normal -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Dear Maintainer, In https://github.com/kennethreitz/requests/pull/2567 upstream is considering a patch to make it easier for Debian and other downstream consumers to devendorized the bundled urllib3 and chardet libraries. I've done some extensive testing of this as you can see in my comment on the above PR. Attached is a patch against the Debian svn package branch for python-requests which drops two previous quilt patches and adds a new one which includes the proposed upstream PR. From my testing it seems to do everything we need it to do with a minimum of delta from upstream. Even less if/when upstream merges the PR! - -- System Information: Debian Release: stretch/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 4.0.0-1-amd64 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages python-requests depends on: ii ca-certificates 20150426 ii python-chardet 2.3.0-1 ii python-urllib3 1.10.4-1 pn python:any <none> python-requests recommends no packages. Versions of packages python-requests suggests: ii python-ndg-httpsclient 0.3.2-1 ii python-openssl 0.14-1 ii python-pyasn1 0.1.7-1 - -- no debconf information -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCAAGBQJVeJvCAAoJEBJutWOnSwa/RdcQAJotaexzbqse4Tr5W++yZNCb Pj4KJ1KYIiXvR15741uwiQ38LTndpAaWU88mklHOz3Pp77ztMlztyseSz0qZlQ/A RFZ5DS3dlybWwqg/1rxCNv3nd8iv0Ex2M3TahqkcOxYmXmwArBFdH5TGXs1tmV3h NbizvXLHX2x1ZfsWemtgCyGR37EfdfUeZqFi2R6UXl8sH+8xbudaNb77fT4Hm+98 rhiA/5QU39/m1w7/yE38XDu35n3+idUksK3B769xKnshBNG1/7UvO0skcPfWm7kf PVPqow5ZZqKCr4nZWJZDPRlp4nYhYt0loFfRbbntef0nX+fYXRLT9Go6UsBlFixf wiXdVY/NaoCCdS26Mi/2ByODddSTkdVarjt3Yp/0TSzRnwyVDHVpT1mjQQDS8iMY KaKbcjbmiGPYraI3Oe6uzWgmi9A3UjUF3onpf6uJYcTw/TPN580Ko5oia5ByCc4D thgorRks2TRHAvPuvqKUvWM8uxcOUOqW819sdVxy5jDhuLrYCUXqQVDzSKbkyNQn gsQqfNUGEd9Ct1XIyei4K0lmyXjf1Oy3Z2xTnokzn7xgWqwM1MhkgHElseB7sJD8 r0itJIPfo7KbD/pQGlZwM7KwVy5Fw2YjGKdXnfIie38XcGOu9Jhm1XFAtXbXovm3 MEUExmUbDxN+6kvtcXt0 =LE0a -----END PGP SIGNATURE-----
Index: debian/changelog =================================================================== --- debian/changelog (revision 32945) +++ debian/changelog (working copy) @@ -1,3 +1,14 @@ +requests (2.7.0-3) UNRELEASED; urgency=medium + + * debian/patches: + - 02_use-system-chardet-and-urllib3.patch and + 04_make-requests.packages.urllib3-same-as-urllib3.patch: Removed in + favor of upstream's pull request #2567 + - 05_upstream_devendorize.patch: Upstream's pull request to better + support the devendorizing of urllib3 and chardet. + + -- Barry Warsaw <[email protected]> Wed, 10 Jun 2015 12:28:58 -0400 + requests (2.7.0-2) unstable; urgency=medium * Upload to unstable. Index: debian/patches/02_use-system-chardet-and-urllib3.patch =================================================================== --- debian/patches/02_use-system-chardet-and-urllib3.patch (revision 32945) +++ debian/patches/02_use-system-chardet-and-urllib3.patch (working copy) @@ -1,129 +0,0 @@ -Description: Use the system python-chardet and python-urllib3 instead of the - embedded copies but provide requests.packages package because it will be - used to supply a stub for ``requests.packages.urllib3``. -Author: Daniele Tricoli <[email protected]> -Forwarded: not-needed -Last-Update: 2015-05-04 - ---- a/requests/adapters.py -+++ b/requests/adapters.py -@@ -11,22 +11,22 @@ - import socket - - from .models import Response --from .packages.urllib3.poolmanager import PoolManager, proxy_from_url --from .packages.urllib3.response import HTTPResponse --from .packages.urllib3.util import Timeout as TimeoutSauce --from .packages.urllib3.util.retry import Retry -+from urllib3.poolmanager import PoolManager, proxy_from_url -+from urllib3.response import HTTPResponse -+from urllib3.util import Timeout as TimeoutSauce -+from urllib3.util.retry import Retry - from .compat import urlparse, basestring - from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers, - prepend_scheme_if_needed, get_auth_from_url, urldefragauth) - from .structures import CaseInsensitiveDict --from .packages.urllib3.exceptions import ConnectTimeoutError --from .packages.urllib3.exceptions import HTTPError as _HTTPError --from .packages.urllib3.exceptions import MaxRetryError --from .packages.urllib3.exceptions import ProxyError as _ProxyError --from .packages.urllib3.exceptions import ProtocolError --from .packages.urllib3.exceptions import ReadTimeoutError --from .packages.urllib3.exceptions import SSLError as _SSLError --from .packages.urllib3.exceptions import ResponseError -+from urllib3.exceptions import ConnectTimeoutError -+from urllib3.exceptions import HTTPError as _HTTPError -+from urllib3.exceptions import MaxRetryError -+from urllib3.exceptions import ProxyError as _ProxyError -+from urllib3.exceptions import ProtocolError -+from urllib3.exceptions import ReadTimeoutError -+from urllib3.exceptions import SSLError as _SSLError -+from urllib3.exceptions import ResponseError - from .cookies import extract_cookies_to_jar - from .exceptions import (ConnectionError, ConnectTimeout, ReadTimeout, SSLError, - ProxyError, RetryError) ---- a/requests/compat.py -+++ b/requests/compat.py -@@ -4,7 +4,7 @@ - pythoncompat - """ - --from .packages import chardet -+import chardet - - import sys - -@@ -39,7 +39,7 @@ - import cookielib - from Cookie import Morsel - from StringIO import StringIO -- from .packages.urllib3.packages.ordered_dict import OrderedDict -+ from urllib3.packages.ordered_dict import OrderedDict - - builtin_str = str - bytes = str ---- a/requests/models.py -+++ b/requests/models.py -@@ -16,10 +16,10 @@ - - from .auth import HTTPBasicAuth - from .cookies import cookiejar_from_dict, get_cookie_header, _copy_cookie_jar --from .packages.urllib3.fields import RequestField --from .packages.urllib3.filepost import encode_multipart_formdata --from .packages.urllib3.util import parse_url --from .packages.urllib3.exceptions import ( -+from urllib3.fields import RequestField -+from urllib3.filepost import encode_multipart_formdata -+from urllib3.util import parse_url -+from urllib3.exceptions import ( - DecodeError, ReadTimeoutError, ProtocolError, LocationParseError) - from .exceptions import ( - HTTPError, MissingSchema, InvalidURL, ChunkedEncodingError, ---- a/setup.py -+++ b/setup.py -@@ -18,12 +18,6 @@ - packages = [ - 'requests', - 'requests.packages', -- 'requests.packages.chardet', -- 'requests.packages.urllib3', -- 'requests.packages.urllib3.packages', -- 'requests.packages.urllib3.contrib', -- 'requests.packages.urllib3.util', -- 'requests.packages.urllib3.packages.ssl_match_hostname', - ] - - requires = [] ---- a/requests/__init__.py -+++ b/requests/__init__.py -@@ -50,7 +50,7 @@ - - # Attempt to enable urllib3's SNI support, if possible - try: -- from .packages.urllib3.contrib import pyopenssl -+ from urllib3.contrib import pyopenssl - pyopenssl.inject_into_urllib3() - except ImportError: - pass ---- a/requests/exceptions.py -+++ b/requests/exceptions.py -@@ -7,7 +7,7 @@ - This module contains the set of Requests' exceptions. - - """ --from .packages.urllib3.exceptions import HTTPError as BaseHTTPError -+from urllib3.exceptions import HTTPError as BaseHTTPError - - - class RequestException(IOError): ---- a/requests/sessions.py -+++ b/requests/sessions.py -@@ -21,7 +21,7 @@ - from .utils import to_key_val_list, default_headers, to_native_string - from .exceptions import ( - TooManyRedirects, InvalidSchema, ChunkedEncodingError, ContentDecodingError) --from .packages.urllib3._collections import RecentlyUsedContainer -+from urllib3._collections import RecentlyUsedContainer - from .structures import CaseInsensitiveDict - - from .adapters import HTTPAdapter Index: debian/patches/03_export-IncompleteRead.patch =================================================================== --- debian/patches/03_export-IncompleteRead.patch (revision 32945) +++ debian/patches/03_export-IncompleteRead.patch (working copy) @@ -7,15 +7,15 @@ --- a/requests/compat.py +++ b/requests/compat.py -@@ -92,6 +92,7 @@ +@@ -40,6 +40,7 @@ from Cookie import Morsel from StringIO import StringIO - from urllib3.packages.ordered_dict import OrderedDict + from .packages.urllib3.packages.ordered_dict import OrderedDict + from httplib import IncompleteRead builtin_str = str bytes = str -@@ -107,6 +108,7 @@ +@@ -54,6 +55,7 @@ from http.cookies import Morsel from io import StringIO from collections import OrderedDict Index: debian/patches/04_make-requests.packages.urllib3-same-as-urllib3.patch =================================================================== --- debian/patches/04_make-requests.packages.urllib3-same-as-urllib3.patch (revision 32945) +++ debian/patches/04_make-requests.packages.urllib3-same-as-urllib3.patch (working copy) @@ -1,46 +0,0 @@ -Description: Make Python import system know that requests.packages.urllib3 and -urllib3 are the same thing. -Author: Jakub Wilk <[email protected]> -Forwarded: not-needed -Bug-Debian: https://bugs.debian.org/769047 -Bug-Debian: https://bugs.debian.org/769496 -Last-Update: 2015-05-03 - ---- a/requests/__init__.py -+++ b/requests/__init__.py -@@ -48,6 +48,28 @@ - __license__ = 'Apache 2.0' - __copyright__ = 'Copyright 2015 Kenneth Reitz' - -+# On Debian make Python import system know that requests.packages.urllib3 -+# and urllib3 are the same thing. -+import pkgutil -+import sys -+import urllib3 -+ -+def _attach_namespace(package, where): -+ # Attach package top namespace -+ sys.modules[where + '.' + package.__name__] = package -+ for loader, name, ispkg in pkgutil.walk_packages(package.__path__, -+ package.__name__ + '.'): -+ try: -+ module = __import__(name) -+ except ImportError: -+ continue -+ sys.modules[where + '.' + name] = module -+ -+_attach_namespace(urllib3, 'requests.packages') -+del _attach_namespace -+# Python 3 needs this imported explicitly. -+import requests.packages -+ - # Attempt to enable urllib3's SNI support, if possible - try: - from urllib3.contrib import pyopenssl ---- a/requests/packages/__init__.py -+++ b/requests/packages/__init__.py -@@ -1,3 +1,3 @@ - from __future__ import absolute_import - --from . import urllib3 -+import urllib3 Index: debian/patches/05_upstream_devendorize.patch =================================================================== --- debian/patches/05_upstream_devendorize.patch (revision 0) +++ debian/patches/05_upstream_devendorize.patch (working copy) @@ -0,0 +1,50 @@ +From b7fc3a1250cb13ed3b55010ccc33f2681f0ffa4a Mon Sep 17 00:00:00 2001 +From: Markus Unterwaditzer <[email protected]> +Date: Fri, 24 Apr 2015 12:05:18 +0200 +Subject: [PATCH 1/2] Import aliases for Debian + +Alternative to #2375 +--- + requests/packages/__init__.py | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +--- a/requests/packages/__init__.py ++++ b/requests/packages/__init__.py +@@ -1,3 +1,36 @@ ++''' ++Debian and other distributions "unbundle" requests' vendored dependencies, and ++rewrite all imports to use the global versions of ``urllib3`` and ``chardet``. ++The problem with this is that not only requests itself imports those ++dependencies, but third-party code outside of the distros' control too. ++ ++In reaction to these problems, the distro maintainers replaced ++``requests.packages`` with a magical "stub module" that imports the correct ++modules. The implementations were varying in quality and all had severe ++problems. For example, a symlink (or hardlink) that links the correct modules ++into place introduces problems regarding object identity, since you now have ++two modules in `sys.modules` with the same API, but different identities:: ++ ++ requests.packages.urllib3 is not urllib3 ++ ++With version ``2.5.2``, requests started to maintain its own stub, so that ++distro-specific breakage would be reduced to a minimum, even though the whole ++issue is not requests' fault in the first place. See ++https://github.com/kennethreitz/requests/pull/2375 for the corresponding pull ++request. ++''' ++ + from __future__ import absolute_import ++import sys ++ ++try: ++ from . import urllib3 ++except ImportError: ++ import urllib3 ++ sys.modules['%s.urllib3' % __name__] = urllib3 + +-from . import urllib3 ++try: ++ from . import chardet ++except ImportError: ++ import chardet ++ sys.modules['%s.chardet' % __name__] = chardet Index: debian/patches/series =================================================================== --- debian/patches/series (revision 32945) +++ debian/patches/series (working copy) @@ -1,4 +1,3 @@ 01_use-system-ca-certificates.patch -02_use-system-chardet-and-urllib3.patch 03_export-IncompleteRead.patch -04_make-requests.packages.urllib3-same-as-urllib3.patch +05_upstream_devendorize.patch Index: debian/rules =================================================================== --- debian/rules (revision 32945) +++ debian/rules (working copy) @@ -25,6 +25,10 @@ override_dh_auto_install: dh_auto_install + rm -rf debian/python-requests/usr/lib/python*/dist-packages/requests/packages/urllib3 + rm -rf debian/python-requests/usr/lib/python*/dist-packages/requests/packages/chardet + rm -rf debian/python3-requests/usr/lib/python*/dist-packages/requests/packages/urllib3 + rm -rf debian/python3-requests/usr/lib/python*/dist-packages/requests/packages/chardet python3 setup.py bdist_wheel \ --universal \ -d $(CURDIR)/debian/tmp/usr/share/python-wheels
_______________________________________________ Python-modules-team mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/python-modules-team

