[packages/python-requests] - up to 2.5.0; bundle libraries for now as requests use newer lib than python provides (from urllib3

arekm arekm at pld-linux.org
Thu Dec 4 11:25:55 CET 2014


commit 27c2bafecae31856418d7b0b65cf8aa9950d39aa
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Dec 4 11:24:53 2014 +0100

    - up to 2.5.0; bundle libraries for now as requests use newer lib than python provides (from urllib3.exceptions import ResponseError -> importError: cannot import name ResponseError

 python-requests.spec             | 34 ++++++++++++++-------
 system-charade-and-urllib3.patch | 66 ++++++++++++++++++++++++++++------------
 2 files changed, 69 insertions(+), 31 deletions(-)
---
diff --git a/python-requests.spec b/python-requests.spec
index 40270b8..85c9c75 100644
--- a/python-requests.spec
+++ b/python-requests.spec
@@ -1,40 +1,49 @@
 #
 # Conditional build:
+%bcond_without	tests	# do not perform "make test"
 %bcond_without	python2	# CPython 2.x module
 %bcond_without	python3	# CPython 3.x module
+%bcond_without	bundled # Bundle Libraries
 #
 %define 	module	requests
 Summary:	HTTP library for Python 2
 Summary(pl.UTF-8):	Biblioteka HTTP dla Pythona 2
 Name:		python-%{module}
-Version:	2.4.3
-Release:	2
+Version:	2.5.0
+Release:	1
 License:	Apache2
 Group:		Development/Languages/Python
 Source0:	https://pypi.python.org/packages/source/r/requests/%{module}-%{version}.tar.gz
-# Source0-md5:	02214b3a179e445545de4b7a98d3dd17
+# Source0-md5:	b8bf3ddca75e7ecf1b6776da1e6e3385
 URL:		http://python-requests.org
+# find . -name '*.py' -exec sed -i -e 's#requests\.packages\.urllib3#urllib3#g' "{}" ";"
 # find . -name '*.py' -exec sed -i -e 's#\.packages\.urllib3#urllib3#g' "{}" ";"
 # find . -name '*.py' -exec sed -i -e 's#from \.packages import chardet#import charade as chardet#g' "{}" ";"
 # + manual removal from setup.py
 Patch0:		system-charade-and-urllib3.patch
 Patch1:		system-cert.patch
 %if %{with python2}
-BuildRequires:	python-charade
 BuildRequires:	python-modules >= 1:2.6
+%if %{without bundled}
+BuildRequires:	python-charade
 BuildRequires:	python-urllib3 >= 1.9.1
 %endif
+%endif
 %if %{with python3}
-BuildRequires:	python3-charade
 BuildRequires:	python3-modules >= 1:3.2
+%if %{without bundled}
+BuildRequires:	python3-charade
 BuildRequires:	python3-urllib3 >= 1.9.1
 %endif
+%endif
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.219
 Requires:	ca-certificates
-Requires:	python-charade
 Requires:	python-modules >= 1:2.6
+%if %{without bundled}
+Requires:	python-charade
 Requires:	python-urllib3 >= 1.9.1
+%endif
 # for python2 only to get SNI working. python3 doesn't need this
 Requires:	python-ndg-httpsclient
 Requires:	python-pyasn1
@@ -70,9 +79,11 @@ Summary:	HTTP library for Python 3
 Summary(pl.UTF-8):	Biblioteka HTTP dla Pythona 3
 Group:		Development/Languages/Python
 Requires:	ca-certificates
-Requires:	python3-charade
 Requires:	python3-modules >= 1:3.2
+%if %{without bundled}
+Requires:	python3-charade
 Requires:	python3-urllib3 >= 1.9.1
+%endif
 
 %description -n python3-requests
 Requests is a HTTP library, written in Python, for human beings.
@@ -99,16 +110,16 @@ Ten pakiet zawiera moduł dla Pythona 3.x.
 
 %prep
 %setup -q -n %{module}-%{version}
-%patch0 -p1
+%{!?with_bundled:%patch0 -p1}
 %patch1 -p1
 
 %build
 %if %{with python2}
-%{__python} setup.py build -b py2
+%{__python} setup.py build -b py2 %{?with_tests:test}
 %endif
 
 %if %{with python3}
-%{__python3} setup.py build -b py3
+%{__python3} setup.py build -b py3 %{?with_tests:test}
 %endif
 
 %install
@@ -135,7 +146,8 @@ rm -rf $RPM_BUILD_ROOT
 	--root=$RPM_BUILD_ROOT
 %endif
 
-%{__rm} -rf $RPM_BUILD_ROOT{%{py_sitescriptdir},%{py3_sitescriptdir}}/%{module}/{cacert.pem,packages}
+%{__rm} -rf $RPM_BUILD_ROOT{%{py_sitescriptdir},%{py3_sitescriptdir}}/%{module}/cacert.pem
+%{!?with_bundled:%{__rm} -rf $RPM_BUILD_ROOT{%{py_sitescriptdir},%{py3_sitescriptdir}}/%{module}/packages}
 
 %clean
 rm -rf $RPM_BUILD_ROOT
diff --git a/system-charade-and-urllib3.patch b/system-charade-and-urllib3.patch
index 8415fcc..ea93fd9 100644
--- a/system-charade-and-urllib3.patch
+++ b/system-charade-and-urllib3.patch
@@ -1,7 +1,7 @@
-diff -urN requests-2.4.3.org/requests/adapters.py requests-2.4.3/requests/adapters.py
---- requests-2.4.3.org/requests/adapters.py	2014-10-06 11:40:10.000000000 +0200
-+++ requests-2.4.3/requests/adapters.py	2014-10-21 17:40:54.823464764 +0200
-@@ -11,21 +11,21 @@
+diff -urN requests-2.5.0.org/requests/adapters.py requests-2.5.0/requests/adapters.py
+--- requests-2.5.0.org/requests/adapters.py	2014-12-01 22:02:39.000000000 +0100
++++ requests-2.5.0/requests/adapters.py	2014-12-04 11:09:50.937837828 +0100
+@@ -11,22 +11,22 @@
  import socket
  
  from .models import Response
@@ -24,6 +24,7 @@ diff -urN requests-2.4.3.org/requests/adapters.py requests-2.4.3/requests/adapte
 -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
@@ -31,12 +32,13 @@ diff -urN requests-2.4.3.org/requests/adapters.py requests-2.4.3/requests/adapte
 +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)
-diff -urN requests-2.4.3.org/requests/compat.py requests-2.4.3/requests/compat.py
---- requests-2.4.3.org/requests/compat.py	2014-08-19 18:52:58.000000000 +0200
-+++ requests-2.4.3/requests/compat.py	2014-10-21 17:40:54.830131661 +0200
+                          ProxyError, RetryError)
+diff -urN requests-2.5.0.org/requests/compat.py requests-2.5.0/requests/compat.py
+--- requests-2.5.0.org/requests/compat.py	2014-08-29 21:37:47.000000000 +0200
++++ requests-2.5.0/requests/compat.py	2014-12-04 11:09:50.944504630 +0100
 @@ -4,7 +4,7 @@
  pythoncompat
  """
@@ -55,9 +57,9 @@ diff -urN requests-2.4.3.org/requests/compat.py requests-2.4.3/requests/compat.p
  
      builtin_str = str
      bytes = str
-diff -urN requests-2.4.3.org/requests/exceptions.py requests-2.4.3/requests/exceptions.py
---- requests-2.4.3.org/requests/exceptions.py	2014-10-05 18:53:35.000000000 +0200
-+++ requests-2.4.3/requests/exceptions.py	2014-10-21 17:40:54.836798554 +0200
+diff -urN requests-2.5.0.org/requests/exceptions.py requests-2.5.0/requests/exceptions.py
+--- requests-2.5.0.org/requests/exceptions.py	2014-12-01 22:02:39.000000000 +0100
++++ requests-2.5.0/requests/exceptions.py	2014-12-04 11:09:50.947838039 +0100
 @@ -7,7 +7,7 @@
  This module contains the set of Requests' exceptions.
  
@@ -67,9 +69,9 @@ diff -urN requests-2.4.3.org/requests/exceptions.py requests-2.4.3/requests/exce
  
  
  class RequestException(IOError):
-diff -urN requests-2.4.3.org/requests/__init__.py requests-2.4.3/requests/__init__.py
---- requests-2.4.3.org/requests/__init__.py	2014-10-06 11:44:17.000000000 +0200
-+++ requests-2.4.3/requests/__init__.py	2014-10-21 17:40:54.820131316 +0200
+diff -urN requests-2.5.0.org/requests/__init__.py requests-2.5.0/requests/__init__.py
+--- requests-2.5.0.org/requests/__init__.py	2014-12-02 00:22:46.000000000 +0100
++++ requests-2.5.0/requests/__init__.py	2014-12-04 11:09:50.934504432 +0100
 @@ -50,7 +50,7 @@
  
  # Attempt to enable urllib3's SNI support, if possible
@@ -79,9 +81,9 @@ diff -urN requests-2.4.3.org/requests/__init__.py requests-2.4.3/requests/__init
      pyopenssl.inject_into_urllib3()
  except ImportError:
      pass
-diff -urN requests-2.4.3.org/requests/models.py requests-2.4.3/requests/models.py
---- requests-2.4.3.org/requests/models.py	2014-10-06 11:40:10.000000000 +0200
-+++ requests-2.4.3/requests/models.py	2014-10-21 17:40:54.840132000 +0200
+diff -urN requests-2.5.0.org/requests/models.py requests-2.5.0/requests/models.py
+--- requests-2.5.0.org/requests/models.py	2014-11-16 18:39:53.000000000 +0100
++++ requests-2.5.0/requests/models.py	2014-12-04 11:09:50.951171470 +0100
 @@ -16,10 +16,10 @@
  
  from .auth import HTTPBasicAuth
@@ -97,9 +99,21 @@ diff -urN requests-2.4.3.org/requests/models.py requests-2.4.3/requests/models.p
      DecodeError, ReadTimeoutError, ProtocolError)
  from .exceptions import (
      HTTPError, RequestException, MissingSchema, InvalidURL, 
-diff -urN requests-2.4.3.org/setup.py requests-2.4.3/setup.py
---- requests-2.4.3.org/setup.py	2014-09-09 18:31:17.000000000 +0200
-+++ requests-2.4.3/setup.py	2014-10-21 17:41:51.558737269 +0200
+diff -urN requests-2.5.0.org/requests/sessions.py requests-2.5.0/requests/sessions.py
+--- requests-2.5.0.org/requests/sessions.py	2014-12-01 22:02:39.000000000 +0100
++++ requests-2.5.0/requests/sessions.py	2014-12-04 11:09:51.081174694 +0100
+@@ -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 -urN requests-2.5.0.org/setup.py requests-2.5.0/setup.py
+--- requests-2.5.0.org/setup.py	2014-09-10 17:30:41.000000000 +0200
++++ requests-2.5.0/setup.py	2014-12-04 11:10:15.661783566 +0100
 @@ -18,13 +18,6 @@
  
  packages = [
@@ -114,3 +128,15 @@ diff -urN requests-2.4.3.org/setup.py requests-2.4.3/setup.py
  ]
  
  requires = []
+diff -urN requests-2.5.0.org/test_requests.py requests-2.5.0/test_requests.py
+--- requests-2.5.0.org/test_requests.py	2014-12-01 23:26:18.000000000 +0100
++++ requests-2.5.0/test_requests.py	2014-12-04 11:09:51.094508361 +0100
+@@ -1532,7 +1532,7 @@
+ 
+ 
+ def test_urllib3_retries():
+-    from requests.packages.urllib3.util import Retry
++    from urllib3.util import Retry
+     s = requests.Session()
+     s.mount('https://', HTTPAdapter(max_retries=Retry(
+         total=2, status_forcelist=[500]
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-requests.git/commitdiff/27c2bafecae31856418d7b0b65cf8aa9950d39aa



More information about the pld-cvs-commit mailing list