Accepting request 494948 from devel:languages:python
1 OBS-URL: https://build.opensuse.org/request/show/494948 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-requests?expand=0&rev=41
This commit is contained in:
commit
63ac96412f
29
PACKAGING_NOTES
Normal file
29
PACKAGING_NOTES
Normal file
@ -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.
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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 <<END
|
||||
import sys, pkg_resources
|
||||
from requests.packages.urllib3 import __version__
|
||||
required = "urllib3 >= {}".format(__version__)
|
||||
dist = pkg_resources.get_distribution(required)
|
||||
if dist is None or not dist.location.startswith("%{_prefix}"):
|
||||
sys.exit(1)
|
||||
END
|
||||
|
||||
%files
|
||||
# exclude tests connecting to TARPIT
|
||||
%python_exec -m pytest tests -k "not (TestTimeout and connect)"
|
||||
|
||||
%files %{python_files}
|
||||
%defattr(-,root,root)
|
||||
%doc HISTORY.rst LICENSE NOTICE README.rst
|
||||
%{python_sitelib}/requests/
|
||||
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5722cd09762faa01276230270ff16af7acf7c5c45d623868d9ba116f15791ce8
|
||||
size 557508
|
32
requests-do-not-use-bundle.patch
Normal file
32
requests-do-not-use-bundle.patch
Normal file
@ -0,0 +1,32 @@
|
||||
Index: requests-2.13.0/setup.py
|
||||
===================================================================
|
||||
--- requests-2.13.0.orig/setup.py
|
||||
+++ requests-2.13.0/setup.py
|
||||
@@ -36,17 +36,9 @@ if sys.argv[-1] == 'publish':
|
||||
packages = [
|
||||
'requests',
|
||||
'requests.packages',
|
||||
- 'requests.packages.chardet',
|
||||
- 'requests.packages.idna',
|
||||
- 'requests.packages.urllib3',
|
||||
- 'requests.packages.urllib3.packages',
|
||||
- 'requests.packages.urllib3.contrib',
|
||||
- 'requests.packages.urllib3.util',
|
||||
- 'requests.packages.urllib3.packages.ssl_match_hostname',
|
||||
- 'requests.packages.urllib3.packages.backports',
|
||||
]
|
||||
|
||||
-requires = []
|
||||
+requires = ['chardet', 'idna', 'urllib3 >= #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,
|
12
set_urllib3_version.sh
Normal file
12
set_urllib3_version.sh
Normal file
@ -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
|
@ -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)
|
3
v2.13.0.tar.gz
Normal file
3
v2.13.0.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:48fd188aaa388b4193bf7b917cf861a00eafacad651148475bc65ffaef445627
|
||||
size 3341123
|
Loading…
Reference in New Issue
Block a user