From e9f9b2b5c01b1fec12f7bc2c2214333c9ca07304 Mon Sep 17 00:00:00 2001 From: Arun SAG Date: Thu, 25 Oct 2012 01:06:30 +0530 Subject: [PATCH 1/2] Updated to requests 0.14.1 --- .gitignore | 1 + python-requests.spec | 36 +++++++++++++++++++----------------- sources | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index efd9e4f..321be65 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /requests-0.10.6.tar.gz /requests-0.11.1.tar.gz /requests-0.13.1.tar.gz +/requests-0.14.1.tar.gz diff --git a/python-requests.spec b/python-requests.spec index 473fb3d..bb7e940 100644 --- a/python-requests.spec +++ b/python-requests.spec @@ -3,10 +3,11 @@ %else %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")} %endif - +# Turn off the brp-python-bytecompile script +#%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') Name: python-requests -Version: 0.13.1 -Release: 3%{?dist} +Version: 0.14.1 +Release: 1%{?dist} Summary: HTTP library, written in Python, for human beings License: ISC and MIT @@ -14,7 +15,7 @@ URL: http://pypi.python.org/pypi/requests Source0: http://pypi.python.org/packages/source/r/requests/requests-%{version}.tar.gz BuildArch: noarch -BuildRequires: python-devel +BuildRequires: python2-devel Requires: ca-certificates @@ -28,14 +29,11 @@ designed to make HTTP requests easy for developers. %package -n python3-requests Summary: HTTP library, written in Python, for human beings BuildRequires: python3-devel -Requires: python3-chardet %description -n python3-requests Most existing Python modules for sending HTTP requests are extremely verbose and cumbersome. Python’s built-in urllib2 module provides most of the HTTP capabilities you should need, but the API is thoroughly broken. This library is designed to make HTTP requests easy for developers. -%else -Requires: python-chardet %endif @@ -43,20 +41,27 @@ Requires: python-chardet %setup -q -n requests-%{version} %build -%{__python} setup.py build %if 0%{?_with_python3} %{__python3} setup.py build %endif - +%{__python} setup.py build %install rm -rf $RPM_BUILD_ROOT -%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT %if 0%{?_with_python3} -%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT +PYTHONDONTWRITEBYTECODE=1 %{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT +#%py_byte_compile %{__python} %{buildroot}%{python3_sitelib}/requests/packages/chardet2 +#%py_byte_compile %{__python} %{buildroot}%{python3_sitelib}/requests/packages/oauthlib +#%py_byte_compile %{__python} %{buildroot}%{python3_sitelib}/requests/packages/urllib3 +#%py_byte_compile %{__python} %{buildroot}%{python3_sitelib}/requests/*.py %endif - +PYTHONDONTWRITEBYTECODE=1 %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT +#%py_byte_compile %{__python} %{buildroot}%{python_sitelib}/requests/packages/chardet +#%py_byte_compile %{__python} %{buildroot}%{python_sitelib}/requests/packages/oauthlib +#%py_byte_compile %{__python} %{buildroot}%{python_sitelib}/requests/packages/urllib3 +#%py_byte_compile %{__python} %{buildroot}%{python_sitelib}/requests/*.py +# %files %defattr(-,root,root,-) %doc NOTICE LICENSE README.rst HISTORY.rst @@ -72,11 +77,8 @@ rm -rf $RPM_BUILD_ROOT %changelog -* Sat Aug 04 2012 David Malcolm - 0.13.1-3 -- rebuild for https://fedoraproject.org/wiki/Features/Python_3.3 - -* Sat Jul 21 2012 Fedora Release Engineering - 0.13.1-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild +* Wed Oct 22 2012 Arun S A G 0.14.1-1 +- Updated to latest upstream release * Sun Jun 10 2012 Arun S A G 0.13.1-1 - Updated to latest upstream release 0.13.1 diff --git a/sources b/sources index 6704a5e..611d373 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -31a08091feeefe60817e45122d933219 requests-0.13.1.tar.gz +3de30600072cbc7214ae342d1d08aa46 requests-0.14.1.tar.gz From ad439987b8e3e9318eb645a566a8778a67baa9ef Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 8 Feb 2013 12:36:37 -0800 Subject: [PATCH 2/2] Let brp_python_bytecompile run again, take care of the non-python{2,3} modules by removing them from the python{,3}-requests package that they did not belong in. - Use the certificates in the ca-certificates package instead of the bundled one + https://bugzilla.redhat.com/show_bug.cgi?id=904614 - Fix a problem with cookie handling + https://bugzilla.redhat.com/show_bug.cgi?id=906924 --- python-requests-cookie-handling.patch | 35 +++++++++++ python-requests-system-cert-bundle.patch | 16 +++++ python-requests.spec | 76 +++++++++++++++++++----- 3 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 python-requests-cookie-handling.patch create mode 100644 python-requests-system-cert-bundle.patch diff --git a/python-requests-cookie-handling.patch b/python-requests-cookie-handling.patch new file mode 100644 index 0000000..520dea4 --- /dev/null +++ b/python-requests-cookie-handling.patch @@ -0,0 +1,35 @@ +From 2cecc4bc828fc1754cc26f279ec3ff5cd65cb8f7 Mon Sep 17 00:00:00 2001 +From: Ralph Bean +Date: Thu, 31 Jan 2013 21:38:58 -0500 +Subject: [PATCH] cookie handling + +--- + requests/models.py | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/requests/models.py b/requests/models.py +index 2193c6e..0a12237 100644 +--- a/requests/models.py ++++ b/requests/models.py +@@ -17,7 +17,7 @@ from .structures import CaseInsensitiveDict + from .status_codes import codes + + from .auth import HTTPBasicAuth, HTTPProxyAuth +-from .cookies import cookiejar_from_dict, extract_cookies_to_jar, get_cookie_header ++from .cookies import cookiejar_from_dict, extract_cookies_to_jar, get_cookie_header, RequestsCookieJar + from .packages.urllib3.exceptions import MaxRetryError, LocationParseError + from .packages.urllib3.exceptions import TimeoutError + from .packages.urllib3.exceptions import SSLError as _SSLError +@@ -207,7 +207,8 @@ class Request(object): + extract_cookies_to_jar(self.cookies, self, resp) + + # Save cookies in Response. +- response.cookies = self.cookies ++ response.cookies = RequestsCookieJar() ++ extract_cookies_to_jar(response.cookies, self, resp) + + # Save cookies in Session. + for cookie in self.cookies: +-- +1.8.1 + diff --git a/python-requests-system-cert-bundle.patch b/python-requests-system-cert-bundle.patch new file mode 100644 index 0000000..198e4c2 --- /dev/null +++ b/python-requests-system-cert-bundle.patch @@ -0,0 +1,16 @@ +Index: requests-0.14.1/requests/certs.py +=================================================================== +--- requests-0.14.1.orig/requests/certs.py ++++ requests-0.14.1/requests/certs.py +@@ -21,7 +21,10 @@ def where(): + return certifi.where() + else: + f = os.path.split(__file__)[0] +- return os.path.join(f, 'cacert.pem') ++ path = os.path.join(f, 'cacert.pem') ++ if os.path.exists(path): ++ return path ++ return None + + if __name__ == '__main__': + print(where()) diff --git a/python-requests.spec b/python-requests.spec index bb7e940..7771692 100644 --- a/python-requests.spec +++ b/python-requests.spec @@ -1,19 +1,23 @@ -%if 0%{?fedora} > 12 || 0%{?rhel} > 6 +%if 0%{?fedora} %global _with_python3 1 %else %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")} %endif -# Turn off the brp-python-bytecompile script -#%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') Name: python-requests Version: 0.14.1 -Release: 1%{?dist} +Release: 4%{?dist} Summary: HTTP library, written in Python, for human beings License: ISC and MIT URL: http://pypi.python.org/pypi/requests Source0: http://pypi.python.org/packages/source/r/requests/requests-%{version}.tar.gz - +# Separate response cookies from request cookies discussed here: +# https://github.com/fedora-infra/python-fedora/pull/6 +Patch0: python-requests-cookie-handling.patch +# Use the system certificates in ca-certificates. This patch causes util.py +# to search for the system bundle (whereas now the return value of +# certs.where() causes it to always use the bundled version. +Patch1: python-requests-system-cert-bundle.patch BuildArch: noarch BuildRequires: python2-devel @@ -40,28 +44,59 @@ designed to make HTTP requests easy for developers. %prep %setup -q -n requests-%{version} +%patch0 -p1 +%patch1 -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 +### chardet/2 is available as python-chardet and python3-chardet so +### those may be easy to unbundle as well (will need patching, but looks +### like a single file, compat.py) +### oauthlib isn't packaged yet (and not in requests-1.0.0) +### but the code in requests will already prefer the system version to +### the bundled version + +# Unbundle the certificate bundle from mozilla. +rm -rf requests/cacert.pem + +%if 0%{?_with_python3} +rm -rf %{py3dir} +cp -a . %{py3dir} +%endif # with_python3 + + %build %if 0%{?_with_python3} +pushd %{py3dir} +rm -rf requests/packages/chardet +# Note -- this means that requests.auth.OAuth1 won't work in py3. +# But, as there isn't an oauthlib for py3, this didn't work anyway. +# Could patch upstream's code to be more explicit about this but +# requests-1.0.x dropped this functionality anyway +rm -rf requests/packages/oauthlib %{__python3} setup.py build +popd %endif + +rm -rf requests/packages/chardet2 %{__python} setup.py build %install rm -rf $RPM_BUILD_ROOT %if 0%{?_with_python3} -PYTHONDONTWRITEBYTECODE=1 %{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT -#%py_byte_compile %{__python} %{buildroot}%{python3_sitelib}/requests/packages/chardet2 -#%py_byte_compile %{__python} %{buildroot}%{python3_sitelib}/requests/packages/oauthlib -#%py_byte_compile %{__python} %{buildroot}%{python3_sitelib}/requests/packages/urllib3 -#%py_byte_compile %{__python} %{buildroot}%{python3_sitelib}/requests/*.py +pushd %{py3dir} +%{__python3} setup.py install --skip-build --root $RPM_BUILD_ROOT +popd %endif -PYTHONDONTWRITEBYTECODE=1 %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT -#%py_byte_compile %{__python} %{buildroot}%{python_sitelib}/requests/packages/chardet -#%py_byte_compile %{__python} %{buildroot}%{python_sitelib}/requests/packages/oauthlib -#%py_byte_compile %{__python} %{buildroot}%{python_sitelib}/requests/packages/urllib3 -#%py_byte_compile %{__python} %{buildroot}%{python_sitelib}/requests/*.py -# +%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT + %files %defattr(-,root,root,-) %doc NOTICE LICENSE README.rst HISTORY.rst @@ -77,6 +112,15 @@ PYTHONDONTWRITEBYTECODE=1 %{__python} setup.py install -O1 --skip-build --root $ %changelog +* Fri Feb 8 2013 Toshio Kuratomi - 0.14.1-3 +- Let brp_python_bytecompile run again, take care of the non-python{2,3} modules + by removing them from the python{,3}-requests package that they did not belong + in. +- Use the certificates in the ca-certificates package instead of the bundled one + + https://bugzilla.redhat.com/show_bug.cgi?id=904614 +- Fix a problem with cookie handling + + https://bugzilla.redhat.com/show_bug.cgi?id=906924 + * Wed Oct 22 2012 Arun S A G 0.14.1-1 - Updated to latest upstream release