diff --git a/PACKAGING_NOTES b/PACKAGING_NOTES new file mode 100644 index 0000000..622d4c0 --- /dev/null +++ b/PACKAGING_NOTES @@ -0,0 +1,29 @@ +Requests is a tricky package. + +The unbundling of urllib3 is unsupported by upstream; AFAICT, mostly because +people are being unreasonable and *third-party packages* expect the bundled +urllib3 to exist. And requests upstream wants to support that usecase. + +Therefore, extra care must be taken with the unbundling. + +First, upstream also recognizes that we distributors will unbundle, and +actually include a helpful shim in requests/packages/__init__.py. This is to +make sure that importing `requests.packages.urllib3` works even if it is +unbundled, and also that you will get the identical import (unlike if we +installed symlinks, in which case Python would consider `r.p.urrlib3` and +`urllib3` to be different packages. See the file __init__.py for more +information. + +We want to keep the shim, so we must install requests/packages/__init__.py +even though we don't install the subdirectories. + +Second, it is our job to set requirements in the egg-info properly, so that +users of virtualenvs get the right thing in certain unusual configurations. + +Third, requests are at times sensitive to version of urllib3. Historically, +requests even bundled pre-release versions. This will probably not happen +again, but it does mean that we must express requirements for a certain +version of urllib3. I have taken some pains to make the build fail if the +right version of urllib3 is not present. Make sure that urllib3 is updated +first, and run `set_urllib3_version.sh` to update the definition in the spec +file. diff --git a/no-default-cacert.patch b/no-default-cacert.patch index e73b7ca..1c7a962 100644 --- a/no-default-cacert.patch +++ b/no-default-cacert.patch @@ -46,3 +46,15 @@ Index: requests-2.12.4/requests/certs.py if __name__ == '__main__': print(where()) +diff -rupN requests-2.10.0.orig/setup.py requests-2.10.0/setup.py +--- requests-2.10.0.orig/setup.py 2016-04-29 18:03:18.000000000 -0400 ++++ requests-2.10.0/setup.py 2016-06-03 01:17:13.549030517 -0400 +@@ -68,7 +68,7 @@ setup( + author_email='me@kennethreitz.com', + url='http://python-requests.org', + packages=packages, +- package_data={'': ['LICENSE', 'NOTICE'], 'requests': ['*.pem']}, ++ package_data={'': ['LICENSE', 'NOTICE']}, + package_dir={'requests': 'requests'}, + include_package_data=True, + install_requires=requires, diff --git a/python-requests.changes b/python-requests.changes index f22d200..71bb78d 100644 --- a/python-requests.changes +++ b/python-requests.changes @@ -1,3 +1,21 @@ +------------------------------------------------------------------- +Tue May 2 07:03:13 UTC 2017 - alarrosa@suse.com + +- The following two entries should have been added to the previous + changelog entry. +- Drop urllib3-ssl-default-context.patch +- Add requests-do-not-use-bundle.patch + +------------------------------------------------------------------- +Tue Mar 14 14:37:56 UTC 2017 - jmatejek@suse.com + +- update for multipython build +- synchronize with python 3 version + * drop urllib3-ssl-default-context.patch + * add requests-do-not-use-bundle.patch +- debundle urllib3 and chardet +- enable test suite + ------------------------------------------------------------------- Mon Mar 6 15:09:56 UTC 2017 - jweberhofer@weberhofer.at @@ -137,6 +155,8 @@ update to version v2.12.4 * Just lstrip instead of strip because trailing whitespace already works. * adding rewind for re-POST bodies * Add persistent examples +- update urllib3 requirement to 1.19.1 +- add idna requirement, refresh unbundling patch ------------------------------------------------------------------- Thu Sep 1 07:53:20 UTC 2016 - tbechtold@suse.com diff --git a/python-requests.spec b/python-requests.spec index 9efd25d..80273ad 100644 --- a/python-requests.spec +++ b/python-requests.spec @@ -16,9 +16,8 @@ # -%if 0%{?suse_version} < 1120 -%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} -%endif +%define urllib3_version 1.20 +%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-requests Version: 2.13.0 Release: 0 @@ -26,35 +25,43 @@ Summary: Awesome Python HTTP Library That's Actually Usable License: Apache-2.0 Group: Development/Languages/Python Url: http://python-requests.org/ -Source: https://pypi.io/packages/source/r/requests/requests-%{version}.tar.gz +#Source: https://files.pythonhosted.org/packages/source/r/requests/requests-%{version}.tar.gz +Source: https://github.com/kennethreitz/requests/archive/v%{version}.tar.gz +Source100: PACKAGING_NOTES +Source101: set_urllib3_version.sh # PATCH-FIX-OPENSUSE no-default-cacert.patch -- Completely ignore the internal CA bundle. Patch0: no-default-cacert.patch -# PATCH-FIX-UPSTREAM update urllib3 to do the proper passthrough to set_default_verify_paths -Patch1: urllib3-ssl-default-context.patch +# PATCH-FIX-OPENSUSE requests-do-not-use-bundle.patch -- Use system libraries instead of bundled ones. +Patch1: requests-do-not-use-bundle.patch +BuildRequires: %{python_module devel} +BuildRequires: %{python_module py} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module urllib3 >= %urllib3_version} +BuildRequires: ca-certificates BuildRequires: python -BuildRequires: python-devel -BuildRequires: python-py -BuildRequires: python-setuptools +BuildRequires: python-rpm-macros +# SECTION test requirements +BuildRequires: %{python_module PySocks >= 1.5.6} +BuildRequires: %{python_module chardet} +BuildRequires: %{python_module idna >= 2.2} +BuildRequires: %{python_module pytest-httpbin} +BuildRequires: %{python_module pytest-mock} +BuildRequires: %{python_module pytest} +# /SECTION +Requires: ca-certificates Requires: python # for good measure, at least recommend an actual set of certificates Recommends: ca-certificates-mozilla -Recommends: python-cryptography >= 1.3.4 -# requirements for pyopenssl fallback of bundled urllib3 -Recommends: python-ndg-httpsclient Recommends: python-pyOpenSSL >= 0.14 -Recommends: python-pyasn1 -%if 0%{?suse_version} <= 1200 -BuildRequires: openssl-certs -Requires: openssl-certs -%else -BuildRequires: ca-certificates -Requires: ca-certificates -%endif -%if 0%{?suse_version} >= 1120 +Recommends: python-cryptography >= 1.3.4 +Recommends: python-PySocks >= 1.5.6 +Requires: python-chardet +Requires: python-idna >= 2.2 +Requires: python-py +Requires: python-urllib3 >= %urllib3_version BuildArch: noarch -%else -BuildRoot: %{_tmppath}/%{name}-%{version}-build -%endif + +%python_subpackages %description Requests is an ISC Licensed HTTP library, written in Python, for @@ -82,23 +89,40 @@ Features: %prep %setup -q -n requests-%{version} %patch0 -p1 -pushd requests/packages %patch1 -p1 -popd rm -f requests/cacert.pem +# fill out required urllib3 version +sed -i s/#URLLIB3VERSION#/%{urllib3_version}/ setup.py +echo "urllib3 >= %{urllib3_version}" >> requirements.txt +# drop shebang from certs.py +sed -i '1s/^#!.*$//' requests/certs.py + %build -python setup.py build +%python_build %install -python setup.py install \ - --root=%{buildroot} --prefix=%{_prefix} +%python_install +# check that urllib3 is not installed +test ! -e %{buildroot}%{python3_sitelib}/requests/packages/urllib3 -# Tests require network access. -# %check -# python test_requests.py +%check +# first check that we have a good version of urllib3 +# DO NOT DISABLE THIS TEST unless you know what you are doing +# see PACKAGING_NOTES for details +python3 <= #URLLIB3VERSION#'] + test_requirements = ['pytest>=2.8.0', 'pytest-httpbin==0.0.7', 'pytest-cov', 'pytest-mock'] + + with open('requests/__init__.py', 'r') as fd: +@@ -72,7 +64,7 @@ setup( + packages=packages, + package_data={'': ['LICENSE', 'NOTICE']}, + package_dir={'requests': 'requests'}, +- include_package_data=True, ++ include_package_data=False, + install_requires=requires, + license='Apache 2.0', + zip_safe=False, diff --git a/set_urllib3_version.sh b/set_urllib3_version.sh new file mode 100644 index 0000000..609ad28 --- /dev/null +++ b/set_urllib3_version.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +wd=$PWD +tmpdir=`mktemp -d` +cd $tmpdir +tar xzf $wd/requests-*.tar.gz +cd requests-* +version=`python3 -c 'from requests.packages.urllib3 import __version__; print(__version__, end="")'` +cd ../.. +rm -rf $tmpdir +cd $wd +sed -i 's/%define urllib3_version .*$/%define urllib3_version '"$version"'/' python-requests.spec diff --git a/urllib3-ssl-default-context.patch b/urllib3-ssl-default-context.patch deleted file mode 100644 index 50f9479..0000000 --- a/urllib3-ssl-default-context.patch +++ /dev/null @@ -1,21 +0,0 @@ -Index: urllib3-1.19.1/urllib3/util/ssl_.py -=================================================================== ---- urllib3-1.19.1.orig/urllib3/util/ssl_.py -+++ urllib3-1.19.1/urllib3/util/ssl_.py -@@ -314,9 +314,13 @@ def ssl_wrap_socket(sock, keyfile=None, - if e.errno == errno.ENOENT: - raise SSLError(e) - raise -- elif getattr(context, 'load_default_certs', None) is not None: -- # try to load OS default certs; works well on Windows (require Python3.4+) -- context.load_default_certs() -+ else: -+ if cert_reqs != ssl.CERT_NONE and hasattr(context, 'set_default_verify_paths'): -+ context.set_default_verify_paths() -+ -+ if getattr(context, 'load_default_certs', None) is not None: -+ # try to load OS default certs; works well on Windows (require Python3.4+) -+ context.load_default_certs() - - if certfile: - context.load_cert_chain(certfile, keyfile) diff --git a/v2.13.0.tar.gz b/v2.13.0.tar.gz new file mode 100644 index 0000000..ec15bb7 --- /dev/null +++ b/v2.13.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48fd188aaa388b4193bf7b917cf861a00eafacad651148475bc65ffaef445627 +size 3341123