From 25d0586d70b755b5fea8dded90836816fb855149 Mon Sep 17 00:00:00 2001 From: Daniele Tricoli Date: Wed, 10 Jun 2015 22:46:16 +0000 Subject: Cherry pick upstream devendorize patch --- debian/changelog | 13 +++ .../02_use-system-chardet-and-urllib3.patch | 129 --------------------- debian/patches/03_export-IncompleteRead.patch | 6 +- ...requests.packages.urllib3-same-as-urllib3.patch | 46 -------- debian/patches/05_upstream_devendorize.patch | 50 ++++++++ debian/patches/series | 3 +- 6 files changed, 67 insertions(+), 180 deletions(-) delete mode 100644 debian/patches/02_use-system-chardet-and-urllib3.patch delete mode 100644 debian/patches/04_make-requests.packages.urllib3-same-as-urllib3.patch create mode 100644 debian/patches/05_upstream_devendorize.patch diff --git a/debian/changelog b/debian/changelog index 6e2eef5..50c7653 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +requests (2.7.0-3) UNRELEASED; urgency=medium + + [ Barry Warsaw ] + * 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. + (Closes: #771349, #788383) + + -- Daniele Tricoli Thu, 11 Jun 2015 00:41:05 +0200 + requests (2.7.0-2) unstable; urgency=medium * Upload to unstable. diff --git a/debian/patches/02_use-system-chardet-and-urllib3.patch b/debian/patches/02_use-system-chardet-and-urllib3.patch deleted file mode 100644 index 956ffb8..0000000 --- a/debian/patches/02_use-system-chardet-and-urllib3.patch +++ /dev/null @@ -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 -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 diff --git a/debian/patches/03_export-IncompleteRead.patch b/debian/patches/03_export-IncompleteRead.patch index d953df6..82938eb 100644 --- a/debian/patches/03_export-IncompleteRead.patch +++ b/debian/patches/03_export-IncompleteRead.patch @@ -7,15 +7,15 @@ Last-Update: 2014-10-23 --- 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 diff --git a/debian/patches/04_make-requests.packages.urllib3-same-as-urllib3.patch b/debian/patches/04_make-requests.packages.urllib3-same-as-urllib3.patch deleted file mode 100644 index 0e4db29..0000000 --- a/debian/patches/04_make-requests.packages.urllib3-same-as-urllib3.patch +++ /dev/null @@ -1,46 +0,0 @@ -Description: Make Python import system know that requests.packages.urllib3 and -urllib3 are the same thing. -Author: Jakub Wilk -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 diff --git a/debian/patches/05_upstream_devendorize.patch b/debian/patches/05_upstream_devendorize.patch new file mode 100644 index 0000000..2a4a9d5 --- /dev/null +++ b/debian/patches/05_upstream_devendorize.patch @@ -0,0 +1,50 @@ +From b7fc3a1250cb13ed3b55010ccc33f2681f0ffa4a Mon Sep 17 00:00:00 2001 +From: Markus Unterwaditzer +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 diff --git a/debian/patches/series b/debian/patches/series index 38fffac..9cf518f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -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 -- cgit v1.2.3 From 31b6ac53f5d257569cd4972b0dca27c50edf166b Mon Sep 17 00:00:00 2001 From: Daniele Tricoli Date: Wed, 10 Jun 2015 23:40:23 +0000 Subject: Remove embedded copy of chardet and urllib3. Previously it was done by 02_use-system-chardet-and-urllib3.patch. --- debian/changelog | 7 ++++++- debian/python-requests.pyremove | 2 ++ debian/python3-requests.pyremove | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 debian/python-requests.pyremove create mode 100644 debian/python3-requests.pyremove diff --git a/debian/changelog b/debian/changelog index 50c7653..7013f14 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,7 +9,12 @@ requests (2.7.0-3) UNRELEASED; urgency=medium support the devendorizing of urllib3 and chardet. (Closes: #771349, #788383) - -- Daniele Tricoli Thu, 11 Jun 2015 00:41:05 +0200 + [ Daniele Tricoli ] + * debian/python{,3}-requests.pyremove + - Remove embedded copy of chardet and urllib3. Previously it was done by + 02_use-system-chardet-and-urllib3.patch. + + -- Daniele Tricoli Thu, 11 Jun 2015 01:39:13 +0200 requests (2.7.0-2) unstable; urgency=medium diff --git a/debian/python-requests.pyremove b/debian/python-requests.pyremove new file mode 100644 index 0000000..2acf4c3 --- /dev/null +++ b/debian/python-requests.pyremove @@ -0,0 +1,2 @@ +requests/packages/chardet +requests/packages/urllib3 diff --git a/debian/python3-requests.pyremove b/debian/python3-requests.pyremove new file mode 100644 index 0000000..2acf4c3 --- /dev/null +++ b/debian/python3-requests.pyremove @@ -0,0 +1,2 @@ +requests/packages/chardet +requests/packages/urllib3 -- cgit v1.2.3 From bf2ae0e6b656de732e81c567708e945d761c8636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= Date: Thu, 11 Jun 2015 07:26:55 +0000 Subject: s/UNRELEASED/unstable/ --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 7013f14..4aaec6a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -requests (2.7.0-3) UNRELEASED; urgency=medium +requests (2.7.0-3) unstable; urgency=medium [ Barry Warsaw ] * debian/patches: -- cgit v1.2.3