diff --git a/Don-t-inject-pyopenssl-into-urllib3.patch b/Don-t-inject-pyopenssl-into-urllib3.patch new file mode 100644 index 0000000000000000000000000000000000000000..df24810bf44145b0e79f2faafe4e338344e8e565 --- /dev/null +++ b/Don-t-inject-pyopenssl-into-urllib3.patch @@ -0,0 +1,38 @@ +From 86b1fa39fdebdb7bc57131c1a198d4d18e104f95 Mon Sep 17 00:00:00 2001 +From: Jeremy Cline +Date: Mon, 16 Apr 2018 10:35:35 -0400 +Subject: [PATCH] Don't inject pyopenssl into urllib3 + +Fedora ships sufficiently new versions of Python 2 and 3 to make this +unnecessary (rhbz 1567862) + +Signed-off-by: Jeremy Cline +--- + requests/__init__.py | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/requests/__init__.py b/requests/__init__.py +index a5b3c9c3..e312d314 100644 +--- a/requests/__init__.py ++++ b/requests/__init__.py +@@ -90,17 +90,6 @@ except (AssertionError, ValueError): + "version!".format(urllib3.__version__, chardet.__version__), + RequestsDependencyWarning) + +-# Attempt to enable urllib3's SNI support, if possible +-try: +- from urllib3.contrib import pyopenssl +- pyopenssl.inject_into_urllib3() +- +- # Check cryptography version +- from cryptography import __version__ as cryptography_version +- _check_cryptography(cryptography_version) +-except ImportError: +- pass +- + # urllib3's DependencyWarnings should be silenced. + from urllib3.exceptions import DependencyWarning + warnings.simplefilter('ignore', DependencyWarning) +-- +2.17.0 + diff --git a/Remove-tests-that-use-the-tarpit.patch b/Remove-tests-that-use-the-tarpit.patch new file mode 100644 index 0000000000000000000000000000000000000000..3b1bcd6d6ce11fe7c5a52afd6e367a74ca3647bc --- /dev/null +++ b/Remove-tests-that-use-the-tarpit.patch @@ -0,0 +1,55 @@ +From 524cd22fb77e69db9bb3f017bbb1d9782c37b0cd Mon Sep 17 00:00:00 2001 +From: Jeremy Cline +Date: Tue, 13 Jun 2017 09:08:09 -0400 +Subject: [PATCH] Remove tests that use the tarpit + +The latest version of Mock has started using systemd containers. The +systemd-nspawn command is being run with --private-network, which +immediately kills connections to something other than localhost. These +tests depend on the connection not being killed immediately and that +they are never responded to. + +Signed-off-by: Jeremy Cline +--- + tests/test_requests.py | 25 ------------------------- + 1 file changed, 25 deletions(-) + +diff --git a/tests/test_requests.py b/tests/test_requests.py +index b8350cb..46b7e9e 100755 +--- a/tests/test_requests.py ++++ b/tests/test_requests.py +@@ -2049,31 +2049,6 @@ class TestTimeout: + except ReadTimeout: + pass + +- @pytest.mark.parametrize( +- 'timeout', ( +- (0.1, None), +- Urllib3Timeout(connect=0.1, read=None) +- )) +- def test_connect_timeout(self, timeout): +- try: +- requests.get(TARPIT, timeout=timeout) +- pytest.fail('The connect() request should time out.') +- except ConnectTimeout as e: +- assert isinstance(e, ConnectionError) +- assert isinstance(e, Timeout) +- +- @pytest.mark.parametrize( +- 'timeout', ( +- (0.1, 0.1), +- Urllib3Timeout(connect=0.1, read=0.1) +- )) +- def test_total_timeout_connect(self, timeout): +- try: +- requests.get(TARPIT, timeout=timeout) +- pytest.fail('The connect() request should time out.') +- except ConnectTimeout: +- pass +- + def test_encoded_methods(self, httpbin): + """See: https://github.com/requests/requests/issues/2316""" + r = requests.request(b'GET', httpbin('get')) +-- +2.9.4 + diff --git a/patch-requests-certs.py-to-use-the-system-CA-bundle.patch b/patch-requests-certs.py-to-use-the-system-CA-bundle.patch new file mode 100644 index 0000000000000000000000000000000000000000..6cb71da9404a9107e9dfd055e2b6013a10b6cd1e --- /dev/null +++ b/patch-requests-certs.py-to-use-the-system-CA-bundle.patch @@ -0,0 +1,26 @@ +diff -uNrp a/requests/certs.py b/requests/certs.py +--- a/requests/certs.py 2019-12-20 15:17:38.304000000 +0800 ++++ b/requests/certs.py 2019-12-20 15:25:18.952000000 +0800 +@@ -11,7 +11,10 @@ If you are packaging Requests, e.g., for + environment, you can change the definition of where() to return a separately + packaged CA bundle. + """ +-from certifi import where ++def where(): ++ """Return the absolute path to the system CA bundle.""" ++ return '/etc/pki/tls/certs/ca-bundle.crt' ++ + + if __name__ == '__main__': + print(where()) +diff -uNrp a/setup.py b/setup.py +--- a/setup.py 2019-12-20 15:17:38.304000000 +0800 ++++ b/setup.py 2019-12-20 15:14:39.212000000 +0800 +@@ -45,7 +45,6 @@ requires = [ + 'chardet>=3.0.2,<3.1.0', + 'idna>=2.5,<2.9', + 'urllib3>=1.21.1,<1.25', +- 'certifi>=2017.4.17' + + ] + test_requirements = [ diff --git a/python-requests.spec b/python-requests.spec new file mode 100644 index 0000000000000000000000000000000000000000..425306ae4ea6a27a962d0169d8d033626299cb9b --- /dev/null +++ b/python-requests.spec @@ -0,0 +1,134 @@ +%bcond_with tests + +Name: python-requests +Version: 2.21.0 +Release: 4 +Summary: Python HTTP Library +License: ASL 2.0 +URL: http://python-requests.org/ +Source0: https://github.com/requests/requests/archive/v%{version}/requests-v%{version}.tar.gz + +#These patches are from Redhat +Patch0: patch-requests-certs.py-to-use-the-system-CA-bundle.patch +Patch2: Remove-tests-that-use-the-tarpit.patch +Patch3: requests-2.12.4-tests_nonet.patch +Patch4: Don-t-inject-pyopenssl-into-urllib3.patch +Patch5: requests-2.20.0-no-py2-httpbin.patch + +BuildArch: noarch + +%description +Requests is an HTTP library, written in Python, as an alternative +to Python's builtin urllib2 which requires work (even +method overrides) to perform basic tasks. +Features of Requests: + - GET, HEAD, POST, PUT, DELETE Requests: + + HTTP Header Request Attachment. + + Data/Params Request Attachment. + + Multipart File Uploads. + + CookieJar Support. + + Redirection History. + + Redirection Recursion Urllib Fix. + + Automatic Decompression of GZipped Content. + + Unicode URL Support. + - Authentication: + + URL + HTTP Auth Registry. + +%package -n python2-requests +Summary: HTTP library, written in Python, for human beings +%{?python_provide:%python_provide python2-requests} +BuildRequires: python2-devel python2-idna python2-chardet python2-urllib3 +%if %{with tests} +BuildRequires: python2-pytest python2-pytest-mock python2-pytest-cov +%endif +Requires: ca-certificates python2-idna python2-chardet python2-urllib3 + +%description -n python2-requests +This package exists only to allow packagers to uniformly depend on +python2-requests. + +%package -n python%{python3_pkgversion}-requests +Summary: Awesome Python HTTP Library That's Actually Usable + +%{?python_provide:%python_provide python%{python3_pkgversion}-requests} + +BuildRequires: python%{python3_pkgversion}-devel +BuildRequires: python%{python3_pkgversion}-chardet +BuildRequires: python%{python3_pkgversion}-urllib3 +BuildRequires: python%{python3_pkgversion}-idna +%if %{with tests} +BuildRequires: python%{python3_pkgversion}-pytest +BuildRequires: python%{python3_pkgversion}-pytest-cov +BuildRequires: python%{python3_pkgversion}-pytest-httpbin +BuildRequires: python%{python3_pkgversion}-pytest-mock +%endif + +Requires: python%{python3_pkgversion}-chardet +Requires: python%{python3_pkgversion}-urllib3 +Requires: python%{python3_pkgversion}-idna + +%description -n python%{python3_pkgversion}-requests +Requests is an ISC Licensed HTTP library, written in Python, for human +beings. +Most existing Python modules for sending HTTP requests are extremely +verbose and cumbersome. Python's builtin urllib2 module provides most of +the HTTP capabilities you should need, but the api is thoroughly broken. +It requires an enormous amount of work (even method overrides) to +perform the simplest of tasks. + +%package_help + +%prep +%autosetup -p1 -n requests-%{version} +rm -rf requests/cacert.pem +sed -i '/#!\/usr\/.*python/d' requests/certs.py + +%build +%py2_build +%py3_build + +%install +%py2_install +%py3_install + +%if %{with tests} +%check +PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} -m pytest -v +PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} -m pytest -v +%endif # tests + +%files -n python2-requests +%license LICENSE +%{python2_sitelib}/*.egg-info +%{python2_sitelib}/requests/ + +%files -n python%{python3_pkgversion}-requests +%defattr(-,root,root) +%license LICENSE +%{python3_sitelib}/*.egg-info +%{python3_sitelib}/requests/ + + +%files help +%defattr(-,root,root) +%doc HISTORY.md README.md + +%changelog +* Fri Dec 20 2019 openEuler Buildteam - 2.21.0-4 +- Type:bugfix +- Id:NA +- SUG:NA +- DESC:modify the patch + +* Wed Oct 30 2019 hexiaowen - 2.21.0-3 +- disable tests + +* Thu Oct 17 2019 openEuler Buildteam - 2.21.0-2 +- Type:bugfix +- Id:NA +- SUG:NA +- DESC:add the provides of python3 + +* Wed Sep 25 2019 openEuler Buildteam - 2.21.0-1 +- Package init + diff --git a/requests-2.12.4-tests_nonet.patch b/requests-2.12.4-tests_nonet.patch new file mode 100644 index 0000000000000000000000000000000000000000..5e097b1bfbb663e887bd211e473d76a378798203 --- /dev/null +++ b/requests-2.12.4-tests_nonet.patch @@ -0,0 +1,11 @@ +--- requests-2.12.4/tests/testserver/server.py 2016-12-21 11:31:56.000000000 -0800 ++++ requests-2.12.4/tests/testserver/server.py.new 2016-12-30 10:40:06.085995065 -0800 +@@ -27,7 +27,7 @@ + """Dummy server using for unit testing""" + WAIT_EVENT_TIMEOUT = 5 + +- def __init__(self, handler=None, host='localhost', port=0, requests_to_handle=1, wait_to_close_event=None): ++ def __init__(self, handler=None, host='127.0.0.1', port=0, requests_to_handle=1, wait_to_close_event=None): + super(Server, self).__init__() + + self.handler = handler or consume_socket_content diff --git a/requests-2.20.0-no-py2-httpbin.patch b/requests-2.20.0-no-py2-httpbin.patch new file mode 100644 index 0000000000000000000000000000000000000000..c3f60b1003b0935f5eb2d834797204d6ec128c21 --- /dev/null +++ b/requests-2.20.0-no-py2-httpbin.patch @@ -0,0 +1,34 @@ +diff --git a/tests/conftest.py b/tests/conftest.py +index cd64a76..1d5ddbb 100644 +--- a/tests/conftest.py ++++ b/tests/conftest.py +@@ -14,11 +14,23 @@ def prepare_url(value): + return inner + + +-@pytest.fixture +-def httpbin(httpbin): +- return prepare_url(httpbin) ++import sys + ++if sys.version_info[0] < 3: ++ @pytest.fixture ++ def httpbin(): ++ pytest.skip('No httpbin for Python 2') + +-@pytest.fixture +-def httpbin_secure(httpbin_secure): +- return prepare_url(httpbin_secure) ++ @pytest.fixture ++ def httpbin_secure(): ++ pytest.skip('No httpbin for Python 2') ++ ++else: ++ @pytest.fixture ++ def httpbin(httpbin): ++ return prepare_url(httpbin) ++ ++ ++ @pytest.fixture ++ def httpbin_secure(httpbin_secure): ++ return prepare_url(httpbin_secure) diff --git a/requests-v2.21.0.tar.gz b/requests-v2.21.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..45f2b3d4ce03ead08f7ddd241748ece87226b409 Binary files /dev/null and b/requests-v2.21.0.tar.gz differ