Blob Blame History Raw
%if 0%{?fedora}
# Upstream is not ready to support python3 yet, so we turn it off.
%global with_python3 0
%endif

%{!?_licensedir: %global license %%doc}

%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2:        %global __python2 /usr/bin/python2}
%{!?python2_sitelib:  %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif

%global modname txrequests

Name:               python-txrequests
Version:            0.9.2
Release:            5%{?dist}
Summary:            Asynchronous Python HTTP for Humans

Group:              Development/Libraries
License:            ASL 2.0
URL:                http://pypi.python.org/pypi/txrequests
Source0:            https://pypi.python.org/packages/source/t/%{modname}/%{modname}-%{version}.tar.gz

BuildArch:          noarch

BuildRequires:      python2-devel
BuildRequires:      python-setuptools
BuildRequires:      python-requests
BuildRequires:      python-twisted-core

%if 0%{?with_python3}
BuildRequires:      python3-devel
BuildRequires:      python3-requests
BuildRequires:      python3-twisted-core
%endif

Requires:           python-requests
Requires:           python-twisted-core

%description
This is a small add-on for the python requests HTTP library.  It makes use
twisted's ThreadPool, so that requests' API returns deferreds.

The additional API and changes are minimal and strive to avoid surprises.

%if 0%{?with_python3}
%package -n python3-txrequests
Summary:            Asynchronous Python HTTP for Humans.
Group:              Development/Libraries

Requires:           python3-requests
Requires:           python3-twisted-core

%description -n python3-txrequests
This is a small add-on for the python requests HTTP library.  It makes use
twisted's ThreadPool, so that requests' API returns deferreds.

The additional API and changes are minimal and strive to avoid surprises.
%endif

%prep
%setup -q -n %{modname}-%{version}

# Nuke this req for epel7
sed -i '/twisted/d' setup.py

# Furthermore, un-pin this for epel7.
# See https://bugzilla.redhat.com/show_bug.cgi?id=1177503
sed -i 's/requests>=1.2.0/requests>=1.1.0/g' setup.py

# Remove bundled egg-info in case it exists
rm -rf %{modname}.egg-info
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif

%build
%{__python2} setup.py build
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif

%install
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root=%{buildroot}
popd
%endif
%{__python2} setup.py install -O1 --skip-build --root=%{buildroot}

%check
%{__python2} setup.py test
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py test
popd
%endif

%files
%doc README.rst
%license LICENSE
%{python2_sitelib}/%{modname}/
%{python2_sitelib}/%{modname}-%{version}*

%if 0%{?with_python3}
%files -n python3-txrequests
%doc README.rst
%license LICENSE
%{python3_sitelib}/%{modname}/
%{python3_sitelib}/%{modname}-%{version}*
%endif

%changelog
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Mon Jan 05 2015 Ralph Bean <rbean@redhat.com> - 0.9.2-3
- Un-pin another requirement for epel7.

* Wed Nov 05 2014 Ralph Bean <rbean@redhat.com> - 0.9.2-2
- Nuke a requirement for epel7.

* Tue Nov 04 2014 Ralph Bean <rbean@redhat.com> - 0.9.2-1
- Initial package for Fedora