+#
# Conditional build:
-%bcond_without python2 # build python 2 module
-%bcond_without python3 # build python 3 module
+%bcond_with tests # perform "make test"
+%bcond_without python2 # CPython 2.x module
+%bcond_without python3 # CPython 3.x module
+%bcond_without bundled # bundled libraries
#
+%define urllib3ver 1.13
%define module requests
-Summary: HTTP library for Python
-Summary(pl.UTF-8): Biblioteka HTTP dla Pythona
+Summary: HTTP library for Python 2
+Summary(pl.UTF-8): Biblioteka HTTP dla Pythona 2
Name: python-%{module}
-Version: 2.0.1
+Version: 2.9.1
Release: 1
License: Apache2
Group: Development/Languages/Python
Source0: https://pypi.python.org/packages/source/r/requests/%{module}-%{version}.tar.gz
-# Source0-md5: 38e61c2856d2ba2782286730241975e6
+# Source0-md5: 0b7f480d19012ec52bab78292efd976d
URL: http://python-requests.org
+# find . -name '*.py' -exec sed -i -e 's#requests\.packages\.urllib3#urllib3#g' "{}" ";"
+# find . -name '*.py' -exec sed -i -e 's#\.packages\.urllib3#urllib3#g' "{}" ";"
+# find . -name '*.py' -exec sed -i -e 's#from \.packages import chardet#import charade as chardet#g' "{}" ";"
+# + manual removal from setup.py
Patch0: system-charade-and-urllib3.patch
Patch1: system-cert.patch
%if %{with python2}
-BuildRequires: python-charade
BuildRequires: python-modules >= 1:2.6
-BuildRequires: python-urllib3
+%if %{without bundled}
+BuildRequires: python-charade
+BuildRequires: python-urllib3 >= %{urllib3ver}
+%endif
+%{?with_tests:BuildRequires: python-pytest >= 2.3.4}
%endif
%if %{with python3}
+BuildRequires: python3-modules >= 1:3.2
+%if %{without bundled}
BuildRequires: python3-charade
-BuildRequires: python3-modules >= 3.2
-BuildRequires: python3-urllib3
+BuildRequires: python3-urllib3 >= %{urllib3ver}
+%endif
+%{?with_tests:BuildRequires: python3-pytest >= 2.3.4}
%endif
BuildRequires: rpm-pythonprov
-BuildRequires: rpmbuild(macros) >= 1.219
+BuildRequires: rpmbuild(macros) >= 1.713
Requires: ca-certificates
-Requires: python-charade
Requires: python-modules >= 1:2.6
-Requires: python-urllib3
+%if %{without bundled}
+Requires: python-charade
+Requires: python-urllib3 >= %{urllib3ver}
+%endif
+# for python2 only to get SNI working. python3 doesn't need this
+Requires: python-ndg-httpsclient
+Requires: python-pyasn1
+Requires: python-pyOpenSSL
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
to perform the simplest of tasks. Things shouldn't be this way. Not in
Python.
+This package contains Python 2.x module.
+
%description -l pl.UTF-8
Requests to napisana w Pythonie biblioteka HTTP dla ludzi.
wymaga dużych nakładów pracy (nawet nadpisań metod) do wykonania
najprostszych zadań. Nie powinno tak być. Nie w Pythonie.
+Ten pakiet zawiera moduł dla Pythona 2.x.
+
%package -n python3-requests
-Summary: HTTP library, written in Python, for human beings
-Summary(pl.UTF-8): Biblioteka HTTP library napisana w Pythonie dla ludzi
+Summary: HTTP library for Python 3
+Summary(pl.UTF-8): Biblioteka HTTP dla Pythona 3
Group: Development/Languages/Python
Requires: ca-certificates
+Requires: python3-modules >= 1:3.2
+%if %{without bundled}
Requires: python3-charade
-Requires: python3-modules >= 3.2
-Requires: python3-urllib3
+Requires: python3-urllib3 >= %{urllib3ver}
+%endif
%description -n python3-requests
Requests is a HTTP library, written in Python, for human beings.
to perform the simplest of tasks. Things shouldn't be this way. Not in
Python.
+This package contains Python 3.x module.
+
%description -n python3-requests -l pl.UTF-8
Requests to napisana w Pythonie biblioteka HTTP dla ludzi.
wymaga dużych nakładów pracy (nawet nadpisań metod) do wykonania
najprostszych zadań. Nie powinno tak być. Nie w Pythonie.
+Ten pakiet zawiera moduł dla Pythona 3.x.
+
%prep
%setup -q -n %{module}-%{version}
-%patch0 -p1
+%{!?with_bundled:%patch0 -p1}
%patch1 -p1
%build
%if %{with python2}
-%{__python} setup.py build -b py2
+%py_build %{?with_tests:test}
+%{?with_tests:cp requirements.txt test_requests.py build-2; cd build-2; PYTHONPATH=$(pwd)/lib %{__python} test_requests.py; cd ..}
%endif
%if %{with python3}
-%{__python3} setup.py build -b py3
+%py3_build %{?with_tests:test}
+%{?with_tests:cp requirements.txt test_requests.py build-3; cd build-3; PYTHONPATH=$(pwd)/lib %{__python3} test_requests.py; cd ..}
%endif
%install
rm -rf $RPM_BUILD_ROOT
%if %{with python2}
-%{__python} setup.py \
- build -b py2 \
- install \
- --skip-build \
- --optimize=2 \
- --root=$RPM_BUILD_ROOT
+%py_install
%py_ocomp $RPM_BUILD_ROOT%{py_sitescriptdir}
%py_comp $RPM_BUILD_ROOT%{py_sitescriptdir}
%py_postclean
%endif
%if %{with python3}
-%{__python3} setup.py \
- build -b py3 \
- install \
- --skip-build \
- --optimize=2 \
- --root=$RPM_BUILD_ROOT
+%py3_install
%endif
-%{__rm} -rf $RPM_BUILD_ROOT{%{py_sitescriptdir},%{py3_sitescriptdir}}/%{module}/{cacert.pem,packages}
+%{__rm} $RPM_BUILD_ROOT{%{py_sitescriptdir},%{py3_sitescriptdir}}/%{module}/cacert.pem
+%{!?with_bundled:%{__rm} -r $RPM_BUILD_ROOT{%{py_sitescriptdir},%{py3_sitescriptdir}}/%{module}/packages}
%clean
rm -rf $RPM_BUILD_ROOT
%defattr(644,root,root,755)
%doc HISTORY.rst README.rst
%{py_sitescriptdir}/%{module}
-%if "%{py_ver}" > "2.4"
%{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
%endif
-%endif
%if %{with python3}
%files -n python3-requests