55fde0
%bcond_without python3
55fde0
55fde0
%global srcname urllib3
55fde0
55fde0
Name:           python-%{srcname}
55fde0
Version:        1.23
721b52
Release:        7.1%{?dist}
55fde0
Summary:        Python HTTP library with thread-safe connection pooling and file post
55fde0
55fde0
License:        MIT
55fde0
URL:            https://github.com/shazow/urllib3
55fde0
Source0:        %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
55fde0
# Used with Python 3.5+
55fde0
Source1:        ssl_match_hostname_py3.py
55fde0
BuildArch:      noarch
55fde0
55fde0
%description
55fde0
Python HTTP module with connection pooling and file POST abilities.
55fde0
55fde0
%package -n python2-%{srcname}
55fde0
Summary:        Python2 HTTP library with thread-safe connection pooling and file post
55fde0
%{?python_provide:%python_provide python2-%{srcname}}
55fde0
55fde0
Requires:       ca-certificates
55fde0
55fde0
# Previously bundled things:
55fde0
Requires:       python2-six
55fde0
Requires:       python2-backports-ssl_match_hostname
55fde0
55fde0
# Secure extra requirements
55fde0
Requires:       python2-ipaddress
55fde0
Requires:       python2-pysocks
55fde0
55fde0
BuildRequires:  python2-devel
55fde0
55fde0
# For tests
55fde0
BuildRequires:  python2-pytest
55fde0
BuildRequires:  python2-mock
55fde0
BuildRequires:  python2-pysocks
55fde0
55fde0
%description -n python2-%{srcname}
55fde0
Python2 HTTP module with connection pooling and file POST abilities.
55fde0
55fde0
55fde0
%if %{with python3}
55fde0
%package -n python3-%{srcname}
55fde0
Summary:        Python3 HTTP library with thread-safe connection pooling and file post
55fde0
55fde0
BuildRequires:  python3-devel
55fde0
# For unittests
55fde0
BuildRequires:  python3-mock
55fde0
BuildRequires:  python3-six
55fde0
BuildRequires:  python3-pysocks
55fde0
BuildRequires:  python3-pytest
55fde0
55fde0
Requires:       ca-certificates
55fde0
Requires:       python3-six
55fde0
Requires:       python3-pysocks
55fde0
55fde0
%description -n python3-%{srcname}
55fde0
Python3 HTTP module with connection pooling and file POST abilities.
55fde0
55fde0
%endif
55fde0
55fde0
%prep
55fde0
%setup -q -n %{srcname}-%{version}
55fde0
# Drop the dummyserver tests in koji.
55fde0
# These require tornado, a Web framework otherwise unused in the distro.
55fde0
rm -rf test/with_dummyserver/
55fde0
rm -rf test/test_connectionpool.py
55fde0
rm -rf dummyserver/
55fde0
# Don't run the Google App Engine tests
55fde0
rm -rf test/appengine/
55fde0
# Lots of these tests started failing, even for old versions, so it has something
55fde0
# to do with Fedora in particular. They don't fail in upstream build infrastructure
55fde0
rm -rf test/contrib/
55fde0
721b52
# Test `test_recent_date` fails if RECENT_DATE is not up to date.
721b52
# Comment from the test:
721b52
#     This test is to make sure that the RECENT_DATE value
721b52
#     doesn't get too far behind what the current date is.
721b52
#     When this test fails update urllib3.connection.RECENT_DATE
721b52
#     according to the rules defined in that file.
721b52
sed -i "s/^RECENT_DATE = datetime.date(2017, 6, 30)$/RECENT_DATE = datetime.date(2019, 2, 19)/" \
721b52
    urllib3/connection.py
721b52
55fde0
%build
55fde0
%py2_build
55fde0
%if %{with python3}
55fde0
%py3_build
55fde0
%endif
55fde0
55fde0
55fde0
%install
55fde0
%py2_install
55fde0
%if %{with python3}
55fde0
%py3_install
55fde0
%endif
55fde0
55fde0
# Unbundle the Python 2 build
55fde0
rm -rf %{buildroot}/%{python2_sitelib}/urllib3/packages/six.py*
55fde0
rm -rf %{buildroot}/%{python2_sitelib}/urllib3/packages/ssl_match_hostname/
55fde0
55fde0
mkdir -p %{buildroot}/%{python2_sitelib}/urllib3/packages/
55fde0
ln -s ../../six.py %{buildroot}/%{python2_sitelib}/urllib3/packages/six.py
55fde0
ln -s ../../six.pyc %{buildroot}/%{python2_sitelib}/urllib3/packages/six.pyc
55fde0
ln -s ../../six.pyo %{buildroot}/%{python2_sitelib}/urllib3/packages/six.pyo
55fde0
55fde0
ln -s ../../backports/ssl_match_hostname %{buildroot}/%{python2_sitelib}/urllib3/packages/ssl_match_hostname
55fde0
55fde0
%if %{with python3}
55fde0
# Unbundle the Python 3 build
55fde0
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py*
55fde0
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/six*
55fde0
rm -rf %{buildroot}/%{python3_sitelib}/urllib3/packages/ssl_match_hostname/
55fde0
55fde0
mkdir -p %{buildroot}/%{python3_sitelib}/urllib3/packages/
55fde0
ln -s ../../six.py %{buildroot}/%{python3_sitelib}/urllib3/packages/six.py
55fde0
ln -s ../../../__pycache__/six.cpython-%{python3_version_nodots}.opt-1.pyc %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
55fde0
ln -s ../../../__pycache__/six.cpython-%{python3_version_nodots}.pyc %{buildroot}/%{python3_sitelib}/urllib3/packages/__pycache__/
55fde0
# urllib3 requires Python 3.5 to use the standard library's match_hostname,
55fde0
# which we ship in Fedora 26, so we can safely replace the bundled version with
55fde0
# this stub which imports the necessary objects.
55fde0
cp %{SOURCE1} %{buildroot}/%{python3_sitelib}/urllib3/packages/ssl_match_hostname.py
55fde0
%endif
55fde0
55fde0
%check
55fde0
py.test-2
55fde0
%if %{with python3}
55fde0
py.test-3
55fde0
%endif
55fde0
55fde0
%files -n python2-%{srcname}
55fde0
%license LICENSE.txt
55fde0
%doc CHANGES.rst README.rst CONTRIBUTORS.txt
55fde0
%{python2_sitelib}/urllib3/
55fde0
%{python2_sitelib}/urllib3-*.egg-info
55fde0
55fde0
55fde0
%if %{with python3}
55fde0
%files -n python3-%{srcname}
55fde0
%license LICENSE.txt
55fde0
%doc CHANGES.rst README.rst CONTRIBUTORS.txt
55fde0
%{python3_sitelib}/urllib3/
55fde0
%{python3_sitelib}/urllib3-*.egg-info
55fde0
%endif
55fde0
55fde0
55fde0
%changelog
721b52
* Tue Aug 20 2019 Tomas Orsava <torsava@redhat.com> - 1.23-7.1
721b52
- Update the RECENT_DATE variable that needs to be kept up-to-date
721b52
8fc530
* Wed Apr 03 2019 Tomas Orsava <torsava@redhat.com> - 1.23-7
8fc530
- Bumping due to problems with modular RPM upgrade path (#1695587)
8fc530
- Related: rhbz#1693974
8fc530
55fde0
* Tue Jul 31 2018 Lumír Balhar <lbalhar@redhat.com> - 1.23-6
55fde0
- Make possible to disable python3 subpackage
55fde0
* Mon Jul 16 2018 Lumír Balhar <lbalhar@redhat.com> - 1.23-5
55fde0
- First version for python27 module