Unbundle python-urllib3.

This commit is contained in:
Ralph Bean 2013-02-28 12:22:15 -05:00
parent 7fe5b101d0
commit 2f898f274c
2 changed files with 105 additions and 12 deletions

View File

@ -0,0 +1,81 @@
From 5d23c608e72025f72e1f3223cb6c7e3979e93c7f Mon Sep 17 00:00:00 2001
From: Ralph Bean <rbean@redhat.com>
Date: Thu, 28 Feb 2013 10:57:20 -0500
Subject: [PATCH] system-urllib3
---
requests/adapters.py | 12 ++++++------
requests/compat.py | 6 +++++-
requests/models.py | 4 ++--
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/requests/adapters.py b/requests/adapters.py
index 5f9d9c7..1f61bd6 100644
--- a/requests/adapters.py
+++ b/requests/adapters.py
@@ -11,17 +11,17 @@ and maintain connections.
import socket
from .models import Response
-from .packages.urllib3.poolmanager import PoolManager, proxy_from_url
-from .packages.urllib3.response import HTTPResponse
+from urllib3.poolmanager import PoolManager, proxy_from_url
+from urllib3.response import HTTPResponse
from .hooks import dispatch_hook
from .compat import urlparse, basestring, urldefrag
from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,
prepend_scheme_if_needed)
from .structures import CaseInsensitiveDict
-from .packages.urllib3.exceptions import MaxRetryError
-from .packages.urllib3.exceptions import TimeoutError
-from .packages.urllib3.exceptions import SSLError as _SSLError
-from .packages.urllib3.exceptions import HTTPError as _HTTPError
+from urllib3.exceptions import MaxRetryError
+from urllib3.exceptions import TimeoutError
+from urllib3.exceptions import SSLError as _SSLError
+from urllib3.exceptions import HTTPError as _HTTPError
from .cookies import extract_cookies_to_jar
from .exceptions import ConnectionError, Timeout, SSLError
diff --git a/requests/compat.py b/requests/compat.py
index 39421ed..d9ab218 100644
--- a/requests/compat.py
+++ b/requests/compat.py
@@ -89,7 +89,11 @@ if is_py2:
import cookielib
from Cookie import Morsel
from StringIO import StringIO
- from .packages.urllib3.packages.ordered_dict import OrderedDict
+
+ try:
+ from collections import OrderedDict
+ except ImportError:
+ from ordereddict import OrderedDict
builtin_str = str
bytes = str
diff --git a/requests/models.py b/requests/models.py
index 5202e6f..218b4f2 100644
--- a/requests/models.py
+++ b/requests/models.py
@@ -17,7 +17,7 @@ from .status_codes import codes
from .auth import HTTPBasicAuth
from .cookies import cookiejar_from_dict, get_cookie_header
-from .packages.urllib3.filepost import encode_multipart_formdata
+from urllib3.filepost import encode_multipart_formdata
from .exceptions import HTTPError, RequestException, MissingSchema, InvalidURL
from .utils import (
stream_untransfer, guess_filename, requote_uri,
@@ -121,7 +121,7 @@ class RequestEncodingMixin(object):
fp = StringIO(fp)
if isinstance(fp, bytes):
fp = BytesIO(fp)
-
+
if ft:
new_v = (fn, fp.read(), ft)
else:
--
1.8.1.2

View File

@ -6,7 +6,7 @@
Name: python-requests Name: python-requests
Version: 1.1.0 Version: 1.1.0
Release: 2%{?dist} Release: 3%{?dist}
Summary: HTTP library, written in Python, for human beings Summary: HTTP library, written in Python, for human beings
License: ASL 2.0 License: ASL 2.0
@ -18,13 +18,23 @@ Patch0: python-requests-system-cert-bundle.patch
# Unbundle python-charade (a fork of python-chardet). # Unbundle python-charade (a fork of python-chardet).
# https://bugzilla.redhat.com/show_bug.cgi?id=904623 # https://bugzilla.redhat.com/show_bug.cgi?id=904623
Patch1: python-requests-system-chardet-not-charade.patch Patch1: python-requests-system-chardet-not-charade.patch
# Unbundle python-charade (a fork of python-urllib3).
# https://bugzilla.redhat.com/show_bug.cgi?id=904623
Patch2: python-requests-system-urllib3.patch
BuildArch: noarch BuildArch: noarch
BuildRequires: python2-devel BuildRequires: python2-devel
BuildRequires: python-chardet BuildRequires: python-chardet
BuildRequires: python-urllib3
Requires: ca-certificates Requires: ca-certificates
Requires: python-chardet Requires: python-chardet
Requires: python-urllib3
%if 0%{?rhel}
BuildRequires: python-ordereddict
Requires: python-ordereddict
%endif
%description %description
Most existing Python modules for sending HTTP requests are extremely verbose and Most existing Python modules for sending HTTP requests are extremely verbose and
@ -37,7 +47,9 @@ designed to make HTTP requests easy for developers.
Summary: HTTP library, written in Python, for human beings Summary: HTTP library, written in Python, for human beings
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: python3-chardet BuildRequires: python3-chardet
BuildRequires: python3-urllib3
Requires: python3-chardet Requires: python3-chardet
Requires: python3-urllib3
%description -n python3-requests %description -n python3-requests
Most existing Python modules for sending HTTP requests are extremely verbose and Most existing Python modules for sending HTTP requests are extremely verbose and
@ -46,21 +58,12 @@ capabilities you should need, but the API is thoroughly broken. This library is
designed to make HTTP requests easy for developers. designed to make HTTP requests easy for developers.
%endif %endif
%prep %prep
%setup -q -n requests-%{version} %setup -q -n requests-%{version}
%patch0 -p1 %patch0 -p1
%patch1 -p1 %patch1 -p1
%patch2 -p1
### TODO: Need to unbundle libraries in the packages directory.
### https://bugzilla.redhat.com/show_bug.cgi?id=904623
### Priority urllib3 since it's still bundled in requests-1.0.x
### And it's a security issue:
### https://bugzilla.redhat.com/show_bug.cgi?id=855322
### https://bugzilla.redhat.com/show_bug.cgi?id=855323
### Review request for urllib3:
### https://bugzilla.redhat.com/show_bug.cgi?id=907688
# Unbundle the certificate bundle from mozilla. # Unbundle the certificate bundle from mozilla.
rm -rf requests/cacert.pem rm -rf requests/cacert.pem
@ -78,6 +81,9 @@ pushd %{py3dir}
# Unbundle chardet. Patch1 switches usage to system chardet. # Unbundle chardet. Patch1 switches usage to system chardet.
rm -rf build/lib/requests/packages/charade rm -rf build/lib/requests/packages/charade
# Unbundle urllib3. Patch1 switches usage to system urllib3.
rm -rf build/lib/requests/packages
popd popd
%endif %endif
@ -86,6 +92,9 @@ popd
# Unbundle chardet. Patch1 switches usage to system chardet. # Unbundle chardet. Patch1 switches usage to system chardet.
rm -rf build/lib/requests/packages/charade rm -rf build/lib/requests/packages/charade
# Unbundle urllib3. Patch1 switches usage to system urllib3.
rm -rf build/lib/requests/packages
%install %install
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
%if 0%{?_with_python3} %if 0%{?_with_python3}
@ -119,8 +128,11 @@ popd
%{python3_sitelib}/requests/ %{python3_sitelib}/requests/
%endif %endif
%changelog %changelog
* Thu Feb 28 2013 Ralph Bean <rbean@redhat.com> - 1.1.0-3
- Unbundled python-urllib3. Using system python-urllib3 now.
- Conditionally include python-ordereddict for el6.
* Wed Feb 27 2013 Ralph Bean <rbean@redhat.com> - 1.1.0-2 * Wed Feb 27 2013 Ralph Bean <rbean@redhat.com> - 1.1.0-2
- Unbundled python-charade/chardet. Using system python-chardet now. - Unbundled python-charade/chardet. Using system python-chardet now.
- Removed deprecated comments and actions against oauthlib unbundling. - Removed deprecated comments and actions against oauthlib unbundling.