Initial import (#907688)
This commit is contained in:
parent
83f941b9be
commit
e2c2602a24
1
.gitignore
vendored
1
.gitignore
vendored
@ -0,0 +1 @@
|
||||
/urllib3-1.5.tar.gz
|
20
python-urllib3-default-ssl-cert-validate.patch
Normal file
20
python-urllib3-default-ssl-cert-validate.patch
Normal file
@ -0,0 +1,20 @@
|
||||
Author: Jamie Strandboge <jamie@canonical.com>
|
||||
Description: require SSL certificate validation by default by using
|
||||
CERT_REQUIRED and using the system /etc/ssl/certs/ca-certificates.crt
|
||||
Bug-Ubuntu: https://launchpad.net/bugs/1047054
|
||||
Modified for Fedora by Ralph Bean <rbean@redhat.com>
|
||||
Bug-Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=855320
|
||||
|
||||
Index: urllib3-1.5/urllib3/connectionpool.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/urllib3/connectionpool.py
|
||||
+++ urllib3-1.5/urllib3/connectionpool.py
|
||||
@@ -504,7 +504,7 @@ class HTTPSConnectionPool(HTTPConnection
|
||||
strict=False, timeout=None, maxsize=1,
|
||||
block=False, headers=None,
|
||||
key_file=None, cert_file=None,
|
||||
- cert_reqs='CERT_NONE', ca_certs=None):
|
||||
+ cert_reqs='CERT_REQUIRED', ca_certs='/etc/ssl/certs/ca-certificates.crt'):
|
||||
|
||||
super(HTTPSConnectionPool, self).__init__(host, port,
|
||||
strict, timeout, maxsize,
|
10
python-urllib3-old-nose-compat.patch
Normal file
10
python-urllib3-old-nose-compat.patch
Normal file
@ -0,0 +1,10 @@
|
||||
Index: urllib3-1.5/setup.cfg
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/setup.cfg
|
||||
+++ urllib3-1.5/setup.cfg
|
||||
@@ -1,5 +1,4 @@
|
||||
[nosetests]
|
||||
-logging-clear-handlers = true
|
||||
with-coverage = true
|
||||
cover-package = urllib3
|
||||
|
89
python-urllib3-py2.6-compat.patch
Normal file
89
python-urllib3-py2.6-compat.patch
Normal file
@ -0,0 +1,89 @@
|
||||
Index: urllib3-1.5/test/test_collections.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/test/test_collections.py
|
||||
+++ urllib3-1.5/test/test_collections.py
|
||||
@@ -122,9 +122,11 @@ class TestLRUContainer(unittest.TestCase
|
||||
def test_iter(self):
|
||||
d = Container()
|
||||
|
||||
- with self.assertRaises(NotImplementedError):
|
||||
+ def to_test():
|
||||
for i in d:
|
||||
self.fail("Iteration shouldn't be implemented.")
|
||||
|
||||
+ self.assertRaises(NotImplementedError, to_test)
|
||||
+
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Index: urllib3-1.5/test/test_connectionpool.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/test/test_connectionpool.py
|
||||
+++ urllib3-1.5/test/test_connectionpool.py
|
||||
@@ -98,8 +98,7 @@ class TestConnectionPool(unittest.TestCa
|
||||
|
||||
def _test(exception, expect):
|
||||
pool._make_request = lambda *args, **kwargs: _raise(exception)
|
||||
- with self.assertRaises(expect):
|
||||
- pool.request('GET', '/')
|
||||
+ self.assertRaises(expect, pool.request, 'GET', '/')
|
||||
|
||||
self.assertEqual(pool.pool.qsize(), POOL_SIZE)
|
||||
|
||||
@@ -114,15 +113,13 @@ class TestConnectionPool(unittest.TestCa
|
||||
# MaxRetryError, not EmptyPoolError
|
||||
# See: https://github.com/shazow/urllib3/issues/76
|
||||
pool._make_request = lambda *args, **kwargs: _raise(HTTPException)
|
||||
- with self.assertRaises(MaxRetryError):
|
||||
- pool.request('GET', '/', retries=1, pool_timeout=0.01)
|
||||
+ self.assertRaises(MaxRetryError, pool.request, 'GET', '/', retries=1, pool_timeout=0.01)
|
||||
self.assertEqual(pool.pool.qsize(), POOL_SIZE)
|
||||
|
||||
def test_assert_same_host(self):
|
||||
c = connection_from_url('http://google.com:80')
|
||||
|
||||
- with self.assertRaises(HostChangedError):
|
||||
- c.request('GET', 'http://yahoo.com:80', assert_same_host=True)
|
||||
+ self.assertRaises(HostChangedError, c.request, 'GET', 'http://yahoo.com:80', assert_same_host=True)
|
||||
|
||||
def test_pool_close(self):
|
||||
pool = connection_from_url('http://google.com:80')
|
||||
@@ -139,16 +136,13 @@ class TestConnectionPool(unittest.TestCa
|
||||
pool.close()
|
||||
self.assertEqual(pool.pool, None)
|
||||
|
||||
- with self.assertRaises(ClosedPoolError):
|
||||
- pool._get_conn()
|
||||
+ self.assertRaises(ClosedPoolError, pool._get_conn)
|
||||
|
||||
pool._put_conn(conn3)
|
||||
|
||||
- with self.assertRaises(ClosedPoolError):
|
||||
- pool._get_conn()
|
||||
+ self.assertRaises(ClosedPoolError, pool._get_conn)
|
||||
|
||||
- with self.assertRaises(Empty):
|
||||
- old_pool_queue.get(block=False)
|
||||
+ self.assertRaises(Empty, old_pool_queue.get, block=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
Index: urllib3-1.5/test/test_poolmanager.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/test/test_poolmanager.py
|
||||
+++ urllib3-1.5/test/test_poolmanager.py
|
||||
@@ -54,13 +54,11 @@ class TestPoolManager(unittest.TestCase)
|
||||
p.clear()
|
||||
self.assertEqual(len(p.pools), 0)
|
||||
|
||||
- with self.assertRaises(ClosedPoolError):
|
||||
- conn_pool._get_conn()
|
||||
+ self.assertRaises(ClosedPoolError, conn_pool._get_conn)
|
||||
|
||||
conn_pool._put_conn(conn)
|
||||
|
||||
- with self.assertRaises(ClosedPoolError):
|
||||
- conn_pool._get_conn()
|
||||
+ self.assertRaises(ClosedPoolError, conn_pool._get_conn)
|
||||
|
||||
self.assertEqual(len(p.pools), 0)
|
||||
|
136
python-urllib3-unbundle.patch
Normal file
136
python-urllib3-unbundle.patch
Normal file
@ -0,0 +1,136 @@
|
||||
Index: urllib3-1.5/urllib3/_collections.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/urllib3/_collections.py
|
||||
+++ urllib3-1.5/urllib3/_collections.py
|
||||
@@ -10,7 +10,10 @@ from threading import Lock
|
||||
try: # Python 2.7+
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
- from .packages.ordered_dict import OrderedDict
|
||||
+ try: # backport package
|
||||
+ from ordereddict import OrderedDict
|
||||
+ except ImportError:
|
||||
+ from .packages.ordered_dict import OrderedDict
|
||||
|
||||
|
||||
__all__ = ['RecentlyUsedContainer']
|
||||
Index: urllib3-1.5/urllib3/connectionpool.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/urllib3/connectionpool.py
|
||||
+++ urllib3-1.5/urllib3/connectionpool.py
|
||||
@@ -51,8 +51,14 @@ from .exceptions import (
|
||||
TimeoutError,
|
||||
)
|
||||
|
||||
-from .packages.ssl_match_hostname import match_hostname, CertificateError
|
||||
-from .packages import six
|
||||
+try:
|
||||
+ from backports.ssl_match_hostname import match_hostname, CertificateError
|
||||
+except ImportError:
|
||||
+ from .packages.ssl_match_hostname import match_hostname, CertificateError
|
||||
+try:
|
||||
+ import six
|
||||
+except ImportError:
|
||||
+ from .packages import six
|
||||
|
||||
|
||||
xrange = six.moves.xrange
|
||||
Index: urllib3-1.5/urllib3/filepost.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/urllib3/filepost.py
|
||||
+++ urllib3-1.5/urllib3/filepost.py
|
||||
@@ -10,8 +10,12 @@ import mimetypes
|
||||
from uuid import uuid4
|
||||
from io import BytesIO
|
||||
|
||||
-from .packages import six
|
||||
-from .packages.six import b
|
||||
+try:
|
||||
+ import six
|
||||
+ from six import b
|
||||
+except ImportError:
|
||||
+ from .packages import six
|
||||
+ from .packages.six import b
|
||||
|
||||
writer = codecs.lookup('utf-8')[3]
|
||||
|
||||
Index: urllib3-1.5/urllib3/response.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/urllib3/response.py
|
||||
+++ urllib3-1.5/urllib3/response.py
|
||||
@@ -11,7 +11,10 @@ import zlib
|
||||
from io import BytesIO
|
||||
|
||||
from .exceptions import DecodeError
|
||||
-from .packages.six import string_types as basestring
|
||||
+try:
|
||||
+ from six import string_types as basestring
|
||||
+except ImportError:
|
||||
+ from .packages.six import string_types as basestring
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
Index: urllib3-1.5/urllib3/util.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/urllib3/util.py
|
||||
+++ urllib3-1.5/urllib3/util.py
|
||||
@@ -18,7 +18,10 @@ except ImportError: # `poll` doesn't exi
|
||||
except ImportError: # `select` doesn't exist on AppEngine.
|
||||
select = False
|
||||
|
||||
-from .packages import six
|
||||
+try:
|
||||
+ import six
|
||||
+except ImporError:
|
||||
+ from .packages import six
|
||||
from .exceptions import LocationParseError
|
||||
|
||||
|
||||
Index: urllib3-1.5/test/test_collections.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/test/test_collections.py
|
||||
+++ urllib3-1.5/test/test_collections.py
|
||||
@@ -1,7 +1,10 @@
|
||||
import unittest
|
||||
|
||||
from urllib3._collections import RecentlyUsedContainer as Container
|
||||
-from urllib3.packages import six
|
||||
+try:
|
||||
+ import six
|
||||
+except ImportError:
|
||||
+ from urllib3.packages import six
|
||||
xrange = six.moves.xrange
|
||||
|
||||
|
||||
Index: urllib3-1.5/test/test_connectionpool.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/test/test_connectionpool.py
|
||||
+++ urllib3-1.5/test/test_connectionpool.py
|
||||
@@ -1,7 +1,10 @@
|
||||
import unittest
|
||||
|
||||
from urllib3.connectionpool import connection_from_url, HTTPConnectionPool
|
||||
-from urllib3.packages.ssl_match_hostname import CertificateError
|
||||
+try:
|
||||
+ from backports.ssl_match_hostname import CertificateError
|
||||
+except ImportError:
|
||||
+ from urllib3.packages.ssl_match_hostname import CertificateError
|
||||
from urllib3.exceptions import (
|
||||
ClosedPoolError,
|
||||
EmptyPoolError,
|
||||
Index: urllib3-1.5/test/test_filepost.py
|
||||
===================================================================
|
||||
--- urllib3-1.5.orig/test/test_filepost.py
|
||||
+++ urllib3-1.5/test/test_filepost.py
|
||||
@@ -1,7 +1,10 @@
|
||||
import unittest
|
||||
|
||||
from urllib3.filepost import encode_multipart_formdata, iter_fields
|
||||
-from urllib3.packages.six import b, u
|
||||
+try:
|
||||
+ from six import b, u
|
||||
+except ImportError:
|
||||
+ from urllib3.packages.six import b, u
|
||||
|
||||
|
||||
BOUNDARY = '!! test boundary !!'
|
149
python-urllib3.spec
Normal file
149
python-urllib3.spec
Normal file
@ -0,0 +1,149 @@
|
||||
%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
|
||||
|
||||
%global srcname urllib3
|
||||
|
||||
Name: python-%{srcname}
|
||||
Version: 1.5
|
||||
Release: 3%{?dist}
|
||||
Summary: Python HTTP library with thread-safe connection pooling and file post
|
||||
|
||||
License: MIT
|
||||
URL: http://urllib3.readthedocs.org/
|
||||
Source0: http://pypi.python.org/packages/source/u/%{srcname}/%{srcname}-%{version}.tar.gz
|
||||
# Patch to change default behaviour to check SSL certs for validity
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=855320
|
||||
Patch0: python-urllib3-default-ssl-cert-validate.patch
|
||||
### TODO: Send this to upstream urllib3
|
||||
# make all imports of things in packages try system copies first
|
||||
Patch1: python-urllib3-unbundle.patch
|
||||
### TODO: Send this upstream
|
||||
# Compatibility with python-2.6's unittest
|
||||
Patch2: python-urllib3-py2.6-compat.patch
|
||||
# Remove logging-clear-handlers from setup.cfg because it's not available in RHEL6's nose
|
||||
Patch100: python-urllib3-old-nose-compat.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
Requires: ca-certificates
|
||||
Requires: python-six
|
||||
|
||||
### TODO: In review https://bugzilla.redhat.com/show_bug.cgi?id=885013
|
||||
# Requires: python-backports-ssl_match_hostname
|
||||
%if 0%{?rhel} <= 6
|
||||
BuildRequires: python-ordereddict
|
||||
Requires: python-ordereddict
|
||||
%endif
|
||||
|
||||
BuildRequires: python2-devel
|
||||
# For unittests
|
||||
BuildRequires: python-nose
|
||||
BuildRequires: python-six
|
||||
BuildRequires: python-tornado
|
||||
|
||||
%if 0%{?with_python3}
|
||||
BuildRequires: python3-devel
|
||||
# For unittests
|
||||
BuildRequires: python3-nose
|
||||
BuildRequires: python3-six
|
||||
BuildRequires: python3-tornado
|
||||
%endif # with_python3
|
||||
|
||||
%description
|
||||
Python HTTP module with connection pooling and file POST abilities.
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%package -n python3-%{srcname}
|
||||
Requires: ca-certificates
|
||||
Requires: python3-six
|
||||
# Note: Will not run with python3 < 3.2 (unless python3-backports-ssl_match_hostname is created)
|
||||
Summary: Python3 HTTP library with thread-safe connection pooling and file post
|
||||
%description -n python3-%{srcname}
|
||||
Python3 HTTP module with connection pooling and file POST abilities.
|
||||
%endif # with_python3
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -n %{srcname}-%{version}
|
||||
|
||||
### TODO: unbundle everything in packages/:
|
||||
# Need:
|
||||
# ssl_match_hostname https://bugzilla.redhat.com/show_bug.cgi?id=885013
|
||||
# rm -rf urllib3/packages/
|
||||
rm -rf urllib3/packages/six*
|
||||
rm -rf urllib3/packages/ordered_dict*
|
||||
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%if 0%{?rhel} && 0%{?rhel} <= 6
|
||||
%patch100 -p1
|
||||
%patch2 -p1
|
||||
%endif
|
||||
|
||||
%if 0%{?with_python3}
|
||||
rm -rf %{py3dir}
|
||||
cp -a . %{py3dir}
|
||||
%endif # with_python3
|
||||
|
||||
%build
|
||||
%{__python} setup.py build
|
||||
|
||||
%if 0%{?with_python3}
|
||||
pushd %{py3dir}
|
||||
%{__python3} setup.py build
|
||||
popd
|
||||
%endif # with_python3
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
%{__python} setup.py install --skip-build --root %{buildroot}
|
||||
|
||||
# dummyserver is part of the unittest framework
|
||||
rm -rf %{buildroot}%{python_sitelib}/dummyserver
|
||||
|
||||
%if 0%{?with_python3}
|
||||
pushd %{py3dir}
|
||||
%{__python3} setup.py install --skip-build --root %{buildroot}
|
||||
|
||||
# dummyserver is part of the unittest framework
|
||||
rm -rf %{buildroot}%{python3_sitelib}/dummyserver
|
||||
popd
|
||||
%endif # with_python3
|
||||
|
||||
%check
|
||||
nosetests
|
||||
|
||||
%if 0%{?with_python3}
|
||||
pushd %{py3dir}
|
||||
nosetests-%{python3_version}
|
||||
popd
|
||||
%endif # with_python3
|
||||
|
||||
%files
|
||||
%doc CHANGES.rst LICENSE.txt README.rst CONTRIBUTORS.txt
|
||||
# For noarch packages: sitelib
|
||||
%{python_sitelib}/*
|
||||
|
||||
%if 0%{?with_python3}
|
||||
%files -n python3-%{srcname}
|
||||
%doc LICENSE.txt
|
||||
# For noarch packages: sitelib
|
||||
%{python3_sitelib}/*
|
||||
%endif # with_python3
|
||||
|
||||
%changelog
|
||||
* Wed Feb 27 2013 Ralph Bean <rbean@redhat.com> - 1.5-3
|
||||
- Renamed patches to python-urllib3-*
|
||||
- Fixed ssl check patch to use the correct cert path for Fedora.
|
||||
- Included dependency on ca-certificates
|
||||
- Cosmetic indentation changes to the .spec file.
|
||||
|
||||
* Tue Feb 5 2013 Toshio Kuratomi <toshio@fedoraproject.org> - 1.5-2
|
||||
- python3-tornado BR and run all unittests on python3
|
||||
|
||||
* Mon Feb 04 2013 Toshio Kuratomi <toshio@fedoraproject.org> 1.5-1
|
||||
- Initial fedora build.
|
||||
|
Loading…
Reference in New Issue
Block a user