f6497a
# Tests need an internet connection, so they are disabled by default
f6497a
%bcond_with online_tests
f6497a
070c3b
%if 0%{?fedora}
070c3b
%global _with_python3 1
070c3b
%else
070c3b
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
070c3b
%endif
070c3b
070c3b
Name:           python-requests
211cd5
Version:        2.6.0
32bf9a
Release:        9%{?dist}
070c3b
Summary:        HTTP library, written in Python, for human beings
070c3b
070c3b
License:        ASL 2.0
070c3b
URL:            http://pypi.python.org/pypi/requests
070c3b
Source0:        http://pypi.python.org/packages/source/r/requests/requests-%{version}.tar.gz
070c3b
# Explicitly use the system certificates in ca-certificates.
070c3b
# https://bugzilla.redhat.com/show_bug.cgi?id=904614
070c3b
Patch0:         python-requests-system-cert-bundle.patch
211cd5
211cd5
# Remove an unnecessary reference to a bundled compat lib in urllib3
211cd5
Patch1:         python-requests-remove-nested-bundling-dep.patch
070c3b
f6497a
# Modify tests to run in pytest so that we can run backported parametrized
f6497a
# tests (Patch4: fix-default-port-handling.patch).
f6497a
# We cannot launch the tests during build as they require internet, but QE
f6497a
# launches them later.
f6497a
# Minimal version of this upstream change:
f6497a
#   https://github.com/psf/requests/commit/6c2942b19865106a3ac65b3bfc1fc93aae2d346c
f6497a
Patch2:         modify-tests-to-run-in-pytest.patch
f6497a
88b19a
# Fix for CVE-2018-18074
88b19a
# Resolved upstream: https://github.com/requests/requests/pull/4718
f6497a
Patch3:         fix-CVE-2018-18074.patch
f6497a
f6497a
# Fix handling of default ports in auth stripping
f6497a
# Resolved upstream: https://github.com/psf/requests/pull/4851
f6497a
Patch4:         fix-default-port-handling.patch
f6497a
f6497a
# Fix a leaking test that was making another test (test_auth_is_stripped_on_redirect_off_host) fail
f6497a
# Resolved upstream: https://github.com/psf/requests/commit/9b63f9cd37d19f2d4bbce42caec112ad0606d8dd
f6497a
Patch5:         fix-leaking-test.patch
88b19a
df199a
# The upstream requests library bundles urllib3 and chardet, and then
df199a
# manipulates the module namespace in order to alias the packages to
df199a
# the system ones if a distribution unbundles them. This however can lead
df199a
# to side effects, such as creating different instances of the modules
df199a
# in memory where changes can happen to a module but not reflected to another,
df199a
# leading to undefined behavior.
df199a
# This patch changes all the import statements for urllib3 and chardet to import
df199a
# from the global namespace, thus avoiding the instance duplication.
df199a
# Partial backport from https://github.com/psf/requests/pull/4067
df199a
# Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1776294
df199a
Patch6: import-urllib3-and-chardet-from-the-global-namespace.patch
df199a
32bf9a
# While the requests.packages aliasing has been removed since
32bf9a
# it caused various issues while it's also an undocumented API,
32bf9a
# much code in the wild still relies on it. This fix ensures
32bf9a
# that while the naming scheme is there for backwards compatibility,
32bf9a
# the submodules contained in the requests.packages namespace
32bf9a
# are properly aliased to the system installed modules.
32bf9a
# Inspired by https://github.com/psf/requests/blob/v2.18.0/requests/packages.py
32bf9a
# Resolves: rhbz#1785607, rhbz#1785666, rhbz#1785696, rhbz#1787679
32bf9a
Patch7: fix-requests.packages-aliasing.patch
32bf9a
070c3b
BuildArch:      noarch
070c3b
BuildRequires:  python2-devel
211cd5
BuildRequires:  python-chardet >= 2.2.1-1
211cd5
BuildRequires:  python-urllib3 >= 1.10.2-1
070c3b
f6497a
%if %{with online_tests}
f6497a
BuildRequires:  pytest
f6497a
%endif
f6497a
070c3b
Requires:       ca-certificates
211cd5
Requires:       python-chardet >= 2.2.1-1
211cd5
Requires:       python-urllib3 >= 1.10.2-1
070c3b
070c3b
%if 0%{?rhel} && 0%{?rhel} <= 6
211cd5
BuildRequires:  python-ordereddict >= 1.1
211cd5
Requires:       python-ordereddict >= 1.1
070c3b
%endif
070c3b
88b19a
Provides:       python2-requests = %{version}-%{release}
88b19a
Obsoletes:      python2-requests < %{version}-%{release}
88b19a
070c3b
%description
070c3b
Most existing Python modules for sending HTTP requests are extremely verbose and 
070c3b
cumbersome. Python’s built-in urllib2 module provides most of the HTTP 
070c3b
capabilities you should need, but the API is thoroughly broken. This library is 
070c3b
designed to make HTTP requests easy for developers.
070c3b
070c3b
%if 0%{?_with_python3}
070c3b
%package -n python3-requests
070c3b
Summary: HTTP library, written in Python, for human beings
070c3b
BuildRequires:  python3-devel
070c3b
BuildRequires:  python3-chardet
070c3b
BuildRequires:  python3-urllib3
f6497a
%if %{with online_tests}
f6497a
BuildRequires:  python3-pytest
f6497a
%endif
070c3b
Requires:       python3-chardet
070c3b
Requires:       python3-urllib3
070c3b
070c3b
%description -n python3-requests
070c3b
Most existing Python modules for sending HTTP requests are extremely verbose and
070c3b
cumbersome. Python’s built-in urllib2 module provides most of the HTTP
070c3b
capabilities you should need, but the API is thoroughly broken. This library is
070c3b
designed to make HTTP requests easy for developers.
070c3b
%endif
070c3b
070c3b
%prep
070c3b
%setup -q -n requests-%{version}
070c3b
070c3b
%patch0 -p1
070c3b
%patch1 -p1
88b19a
%patch2 -p1
f6497a
%patch3 -p1
f6497a
%patch4 -p1
f6497a
%patch5 -p1
df199a
%patch6 -p1
32bf9a
%patch7 -p1
070c3b
070c3b
# Unbundle the certificate bundle from mozilla.
070c3b
rm -rf requests/cacert.pem
070c3b
070c3b
%if 0%{?_with_python3}
070c3b
rm -rf %{py3dir}
070c3b
cp -a . %{py3dir}
070c3b
%endif # with_python3
070c3b
070c3b
%build
070c3b
%if 0%{?_with_python3}
070c3b
pushd %{py3dir}
070c3b
%{__python3} setup.py build
070c3b
211cd5
# Unbundle chardet and urllib3.
211cd5
rm -rf build/lib/requests/packages/chardet
211cd5
rm -rf build/lib/requests/packages/urllib3
211cd5
070c3b
popd
070c3b
%endif
070c3b
88b19a
%py2_build
070c3b
211cd5
# Unbundle chardet and urllib3.
211cd5
rm -rf build/lib/requests/packages/chardet
211cd5
rm -rf build/lib/requests/packages/urllib3
211cd5
070c3b
%install
070c3b
rm -rf $RPM_BUILD_ROOT
070c3b
%if 0%{?_with_python3}
070c3b
pushd %{py3dir}
070c3b
%{__python3} setup.py install --skip-build --root $RPM_BUILD_ROOT
070c3b
popd
070c3b
%endif
070c3b
88b19a
%py2_install
070c3b
f6497a
%if %{with online_tests}
f6497a
# The tests succeed if run locally, but fail in koji.
f6497a
# They require an active network connection to query httpbin.org
f6497a
%check
f6497a
%{__python} -m pytest test_requests.py
f6497a
%if 0%{?_with_python3}
f6497a
pushd %{py3dir}
f6497a
%{__python3} -m pytest test_requests.py
f6497a
popd
f6497a
%endif
f6497a
%endif #with online_tests
070c3b
070c3b
%files
070c3b
%defattr(-,root,root,-)
070c3b
%doc NOTICE LICENSE README.rst HISTORY.rst
88b19a
%{python2_sitelib}/*.egg-info
88b19a
%dir %{python2_sitelib}/requests
88b19a
%{python2_sitelib}/requests/*
070c3b
070c3b
%if 0%{?_with_python3}
070c3b
%files -n python3-requests
070c3b
%{python3_sitelib}/*.egg-info
070c3b
%{python3_sitelib}/requests/
070c3b
%endif
070c3b
070c3b
%changelog
32bf9a
* Wed Feb 19 2020 Charalampos Stratakis <cstratak@redhat.com> - 2.6.0-9
32bf9a
- Bring back the requests.packages aliasing of its submodules
32bf9a
Resolves: rhbz#1811050, rhbz#1811057, rhbz#1811107, rhbz#1811113
32bf9a
df199a
* Thu Oct 24 2019 Charalampos Stratakis <cstratak@redhat.com> - 2.6.0-8
df199a
- Import urllib3 and chardet from the global namespace
df199a
Resolves: rhbz#1776294
df199a
f6497a
* Thu Oct 03 2019 Tomas Orsava <torsava@redhat.com> - 2.6.0-7
f6497a
- Modify tests to run in pytest
f6497a
- Add a bcond online_tests to enable the tests
f6497a
Related: rhbz#1754830
f6497a
f6497a
* Tue Aug 27 2019 Charalampos Stratakis <cstratak@redhat.com> - 2.6.0-6
f6497a
- Fix handling of default ports in auth stripping
f6497a
Resolves: rhbz#1754830
f6497a
88b19a
* Mon Nov 26 2018 Charalampos Stratakis <cstratak@redhat.com> - 2.6.0-5
88b19a
- Fix CVE-2018-18074
88b19a
Resolves: rhbz#1647368
88b19a
211cd5
* Wed Jun 03 2015 Matej Stuchlik <mstuchli@redhat.com> - 2.6.0-1
211cd5
- Update to 2.6.0
88b19a
Resolves: rhbz#1214365
211cd5
211cd5
* Mon Jan 12 2015 Endi S. Dewata <edewata@redhat.com> - 1.1.0-9
211cd5
- Merged headers with different cases.
211cd5
4100f1
* Mon Jan 27 2014 Endi S. Dewata <edewata@redhat.com> - 1.1.0-8
4100f1
- Removed authentication header on redirect.
4100f1
4100f1
* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 1.1.0-7
4100f1
- Mass rebuild 2013-12-27
4100f1
070c3b
* Fri Oct  4 2013 Endi S. Dewata <edewata@redhat.com> - 1.1.0-6
070c3b
- Removed bundled packages.
070c3b
070c3b
* Tue Jun 18 2013 Endi S. Dewata <edewata@redhat.com> - 1.1.0-5
070c3b
- Fixed bogus date in changelog entry.
070c3b
070c3b
* Tue Jun 11 2013 Ralph Bean <rbean@redhat.com> - 1.1.0-4
070c3b
- Correct a rhel conditional on python-ordereddict
070c3b
070c3b
* Thu Feb 28 2013 Ralph Bean <rbean@redhat.com> - 1.1.0-3
070c3b
- Unbundled python-urllib3.  Using system python-urllib3 now.
070c3b
- Conditionally include python-ordereddict for el6.
070c3b
070c3b
* Wed Feb 27 2013 Ralph Bean <rbean@redhat.com> - 1.1.0-2
070c3b
- Unbundled python-charade/chardet.  Using system python-chardet now.
070c3b
- Removed deprecated comments and actions against oauthlib unbundling.
070c3b
  Those are no longer necessary in 1.1.0.
070c3b
- Added links to bz tickets over Patch declarations.
070c3b
070c3b
* Tue Feb 26 2013 Ralph Bean <rbean@redhat.com> - 1.1.0-1
070c3b
- Latest upstream.
070c3b
- Relicense to ASL 2.0 with upstream.
070c3b
- Removed cookie handling patch (fixed in upstream tarball).
070c3b
- Updated cert unbundling patch to match upstream.
070c3b
- Added check section, but left it commented out for koji.
070c3b
070c3b
* Fri Feb  8 2013 Toshio Kuratomi <toshio@fedoraproject.org> - 0.14.1-4
070c3b
- Let brp_python_bytecompile run again, take care of the non-python{2,3} modules
070c3b
  by removing them from the python{,3}-requests package that they did not belong
070c3b
  in.
070c3b
- Use the certificates in the ca-certificates package instead of the bundled one
070c3b
  + https://bugzilla.redhat.com/show_bug.cgi?id=904614
070c3b
- Fix a problem with cookie handling
070c3b
  + https://bugzilla.redhat.com/show_bug.cgi?id=906924
070c3b
070c3b
* Mon Oct 22 2012 Arun S A G <sagarun@gmail.com>  0.14.1-1
070c3b
- Updated to latest upstream release
070c3b
070c3b
* Sun Jun 10 2012 Arun S A G <sagarun@gmail.com> 0.13.1-1
070c3b
- Updated to latest upstream release 0.13.1
070c3b
- Use system provided ca-certificates
070c3b
- No more async requests use grrequests https://github.com/kennethreitz/grequests
070c3b
- Remove gevent as it is no longer required by requests
070c3b
070c3b
* Sun Apr 01 2012 Arun S A G <sagarun@gmail.com> 0.11.1-1
070c3b
- Updated to upstream release 0.11.1
070c3b
070c3b
* Thu Mar 29 2012 Arun S A G <sagarun@gmail.com> 0.10.6-3
070c3b
- Support building package for EL6
070c3b
070c3b
* Tue Mar 27 2012 Rex Dieter <rdieter@fedoraproject.org> 0.10.6-2
070c3b
- +python3-requests pkg
070c3b
070c3b
* Sat Mar 3 2012 Arun SAG <sagarun@gmail.com> - 0.10.6-1
070c3b
- Updated to new upstream version
070c3b
070c3b
* Sat Jan 21 2012 Arun SAG <sagarun@gmail.com> - 0.9.3-1
070c3b
- Updated to new upstream version 0.9.3
070c3b
- Include python-gevent as a dependency for requests.async
070c3b
- Clean up shebangs in requests/setup.py,test_requests.py and test_requests_ext.py
070c3b
070c3b
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8.2-2
070c3b
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
070c3b
070c3b
* Sun Nov 27 2011 Arun SAG <sagarun@gmail.com> - 0.8.2-1
070c3b
- New upstream version
070c3b
- keep alive support
070c3b
- complete removal of cookiejar and urllib2
070c3b
070c3b
* Thu Nov 10 2011 Arun SAG <sagarun@gmail.com> - 0.7.6-1
070c3b
- Updated to new upstream release 0.7.6
070c3b
070c3b
* Thu Oct 20 2011 Arun SAG <sagarun@gmail.com> - 0.6.6-1
070c3b
- Updated to version 0.6.6
070c3b
070c3b
* Fri Aug 26 2011 Arun SAG <sagarun@gmail.com> - 0.6.1-1
070c3b
- Updated to version 0.6.1
070c3b
070c3b
* Sat Aug 20 2011 Arun SAG <sagarun@gmail.com> - 0.6.0-1
070c3b
- Updated to latest version 0.6.0
070c3b
070c3b
* Mon Aug 15 2011 Arun SAG <sagarun@gmail.com> - 0.5.1-2
070c3b
- Remove OPT_FLAGS from build section since it is a noarch package
070c3b
- Fix use of mixed tabs and space
070c3b
- Remove extra space around the word cumbersome in description
070c3b
070c3b
* Sun Aug 14 2011 Arun SAG <sagarun@gmail.com> - 0.5.1-1
070c3b
- Initial package