python-urllib3/python-urllib3.spec
2020-04-26 02:11:41 +00:00

181 lines
6 KiB
RPMSpec

%define module urllib3
Summary: Python 2 HTTP library
Name: python-%{module}
Version: 1.25.9
Release: 1
License: MIT
Group: Development/Python
Url: http://urllib3.readthedocs.org/
Source0: https://files.pythonhosted.org/packages/05/8c/40cd6949373e23081b3ea20d5594ae523e681b6f472e600fbc95ed046a36/urllib3-1.25.9.tar.gz
Source1: ssl_match_hostname_py3.py
BuildArch: noarch
%description
The urllib3 module is a powerful, sanity-friendly HTTP client for Python. It
offers some features that are missing from the Python standard libraries
(urllib and urllib2):
* Thread safety.
* Connection pooling.
* Client-side SSL/TLS verification.
* File uploads with multipart encoding.
* Helpers for retrying requests and dealing with HTTP redirects.
* Support for gzip and deflate encoding.
* Proxy support for HTTP and SOCKS.
The Python standard libraries 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.
This package contains the python2 files.
%package -n python2-%{module}
Summary: Python 3 HTTP library
Group: Development/Python
BuildRequires: python2-setuptools
BuildRequires: python2-six
BuildRequires: pkgconfig(python2)
# For unittests
BuildRequires: python2-mock
BuildRequires: python2-nose
BuildRequires: python2-tornado
Requires: python2-six
Requires: rootcerts
%description -n python2-%{module}
The urllib3 module is a powerful, sanity-friendly HTTP client for Python. It
offers some features that are missing from the Python standard libraries
(urllib and urllib2):
* Thread safety.
* Connection pooling.
* Client-side SSL/TLS verification.
* File uploads with multipart encoding.
* Helpers for retrying requests and dealing with HTTP redirects.
* Support for gzip and deflate encoding.
* Proxy support for HTTP and SOCKS.
The Python standard libraries 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.
This package contains the python3 files.
%files -n python2-%{module}
%doc CHANGES.rst README.rst CONTRIBUTORS.txt
%{py2_puresitedir}/*
#----------------------------------------------------------------------------
%package -n python3-%{module}
Summary: Python 3 HTTP library
Group: Development/Python
BuildRequires: python3-setuptools
BuildRequires: python3-six
BuildRequires: pkgconfig(python3)
# For unittests
BuildRequires: python3-mock
BuildRequires: python3-nose
BuildRequires: python3-tornado
Requires: python3-six
Requires: rootcerts
%description -n python3-%{module}
The urllib3 module is a powerful, sanity-friendly HTTP client for Python. It
offers some features that are missing from the Python standard libraries
(urllib and urllib2):
* Thread safety.
* Connection pooling.
* Client-side SSL/TLS verification.
* File uploads with multipart encoding.
* Helpers for retrying requests and dealing with HTTP redirects.
* Support for gzip and deflate encoding.
* Proxy support for HTTP and SOCKS.
The Python standard libraries 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.
This package contains the python3 files.
%files -n python3-%{module}
%doc CHANGES.rst README.rst CONTRIBUTORS.txt
%{py3_puresitedir}/*
#----------------------------------------------------------------------------
%prep
%setup -q -n %{module}-%{version}
#apply_patches
# Prepare python3 dirs
cp -a . %{py3dir}
%build
# Build first the python2 stuff...
%{__python2} setup.py build
# ... next the python3 stuff
pushd %{py3dir}
%{__python3} setup.py build
popd
%install
################
# Install first the python2 stuff...
%{__python2} setup.py install --skip-build --root %{buildroot}
rm -rf %{buildroot}/%{py2_puresitedir}/urllib3/packages/six.py*
rm -rf %{buildroot}/%{py2_puresitedir}/urllib3/packages/ssl_match_hostname/
mkdir -p %{buildroot}/%{py2_puresitedir}/urllib3/packages/
ln -s ../../six.py %{buildroot}/%{py2_puresitedir}/urllib3/packages/six.py
ln -s ../../six.pyc %{buildroot}/%{py2_puresitedir}/urllib3/packages/six.pyc
ln -s ../../six.pyo %{buildroot}/%{py2_puresitedir}/urllib3/packages/six.pyo
ln -s ../../backports/ssl_match_hostname %{buildroot}/%{py2_puresitedir}/urllib3/packages/ssl_match_hostname
# dummyserver is part of the unittest framework
rm -rf %{buildroot}%{py2_puresitedir}/dummyserver
###############
# ... next the python3 stuff
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root %{buildroot}
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
# dummyserver is part of the unittest framework
rm -rf %{buildroot}%{py3_puresitedir}/dummyserver
popd
%pretrans -p <lua>
path = "%{py2_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