python-urllib3/python-urllib3.spec

146 lines
4.7 KiB
RPMSpec

%define module urllib3
Summary: Python HTTP library with thread-safe connection pooling, file post, and more
Name: python-%{module}
Version: 1.10.4
Release: 2
Source0: https://pypi.python.org/packages/source/u/%{module}/%{module}-%{version}.tar.gz
Source1: ssl_match_hostname_py3.py
License: MIT
Group: Development/Python
Url: http://urllib3.readthedocs.org/
BuildArch: noarch
BuildRequires: pkgconfig(python)
BuildRequires: python-setuptools
Requires: rootcerts
Requires: python-six
#Requires: python-backports-ssl_match_hostname
# For unittests
BuildRequires: python3-nose
BuildRequires: python3-mock
BuildRequires: python3-tornado
BuildRequires: python-tornado
BuildRequires: python-nose
BuildRequires: python-mock
#BuildRequires: python-backports-ssl_match_hostname
BuildRequires: python-six
BuildRequires: python3-six
%description
There are two critical features missing from the Python standard
library: Connection re-using/pooling and file posting. It's not
terribly hard to implement these yourself, but it's much easier to use
a module that already did the work for you.
The Python standard libraries urllib and urllib2 have little to do
with each other. They were designed to be independent and standalone,
each solving a different scope of problems, and urllib3 follows in a
similar vein.
%package -n python3-%{module}
Summary: Python 3 HTTP library with thread-safe connection pooling, file post, and more
Group: Development/Python
BuildRequires: pkgconfig(python3)
BuildRequires: python3-setuptools
BuildRequires: python3-six
Requires: rootcerts
Requires: python3-six
%description -n python3-%{module}
There are two critical features missing from the Python standard
library: Connection re-using/pooling and file posting. It's not
terribly hard to implement these yourself, but it's much easier to use
a module that already did the work for you.
The Python standard libraries urllib and urllib2 have little to do
with each other. They were designed to be independent and standalone,
each solving a different scope of problems, and urllib3 follows in a
similar vein.
%prep
%setup -q -n %{module}-%{version}
%apply_patches
cp -a . %{py3dir}
%build
python setup.py build
pushd %{py3dir}
python3 setup.py build
popd
%install
python setup.py install --skip-build --root %{buildroot}
rm -rf %{buildroot}/%{py_puresitedir}/urllib3/packages/six.py*
rm -rf %{buildroot}/%{py_puresitedir}/urllib3/packages/ssl_match_hostname/
mkdir -p %{buildroot}/%{py_puresitedir}/urllib3/packages/
ln -s ../../six.py %{buildroot}/%{py_puresitedir}/urllib3/packages/six.py
ln -s ../../six.pyc %{buildroot}/%{py_puresitedir}/urllib3/packages/six.pyc
ln -s ../../six.pyo %{buildroot}/%{py_puresitedir}/urllib3/packages/six.pyo
ln -s ../../backports/ssl_match_hostname %{buildroot}/%{py_puresitedir}/urllib3/packages/ssl_match_hostname
# dummyserver is part of the unittest framework
rm -rf %{buildroot}%{py_puresitedir}/dummyserver
pushd %{py3dir}
python3 setup.py install --skip-build --root %{buildroot}
# dummyserver is part of the unittest framework
rm -rf %{buildroot}%{py3_puresitedir}/dummyserver
rm -rf %{buildroot}/%{py3_puresitedir}/urllib3/packages/six.py*
rm -rf %{buildroot}/%{py3_puresitedir}/urllib3/packages/ssl_match_hostname/
mkdir -p %{buildroot}/%{py3_puresitedir}/urllib3/packages/
ln -s ../../six.py %{buildroot}/%{py3_puresitedir}/urllib3/packages/six.py
ln -s ../../six.pyc %{buildroot}/%{py3_puresitedir}/urllib3/packages/six.pyc
ln -s ../../six.pyo %{buildroot}/%{py3_puresitedir}/urllib3/packages/six.pyo
cp %{SOURCE1} %{buildroot}/%{py3_puresitedir}/urllib3/packages/ssl_match_hostname.py
popd
%pretrans -p <lua>
path = "%{py_puresitedir}/urllib3/packages/ssl_match_hostname"
st = posix.stat(path)
if st and st.type == "directory" then
status = os.rename(path, path .. ".rpmmoved")
if not status then
suffix = 0
while not status do
suffix = suffix + 1
status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
end
os.rename(path, path .. ".rpmmoved")
end
end
%pretrans -p <lua> -n python3-%{module}
path = "%{py3_puresitedir}/urllib3/packages/ssl_match_hostname"
st = posix.stat(path)
if st and st.type == "directory" then
status = os.rename(path, path .. ".rpmmoved")
if not status then
suffix = 0
while not status do
suffix = suffix + 1
status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
end
os.rename(path, path .. ".rpmmoved")
end
end
%files
%doc CHANGES.rst README.rst CONTRIBUTORS.txt
%{py_puresitedir}/*
%files -n python3-%{module}
%doc CHANGES.rst README.rst CONTRIBUTORS.txt
%{py3_puresitedir}/*