File python-six.spec of Package python-six

%define realname six
%define srcext   tar.bz2

%if ! 0%{?py_ver:1}
%define py_ver %(python -c "import sys; v=sys.version_info[:2]; print '%%d.%%d'%%v" 2>/dev/null || echo PYTHON-NOT-FOUND)
%endif

# Python 3.x
%if 0%{?suse_version}
%define python3_pkg python3
%define python3 python3
%endif

# EPEL
%if 0%{?rhel} == 6
%define python3_pkg python34
%define python3     python3.4
%endif
%if 0%{?rhel} == 7
%define python3_pkg python36
%define python3     python3.6
%endif

%if ! 0%{?py3_ver:1}
%define py3_ver %(%python3 -c "import sys; v=sys.version_info[:2]; print ('%%d.%%d'%%v)" 2>/dev/null || echo PYTHON3-NOT-FOUND)
%endif
%define py3_gen %(%python3 -c "import sys; v=sys.version_info[:2]; print '%%d%%d'%%v" 2>/dev/null || echo PYTHON3-NOT-FOUND)

%if ! 0%{?python3_sitelib:1}
%define python3_sitelib %(%python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
%endif

# Common info
Name:          python-%{realname}
Version:       1.10.0
Release:       wiz%{?extraver:0.}1%{?dist}
License:       MIT
Group:         Development/Libraries/Python
URL:           https://pypi.python.org/pypi/six
Summary:       Python 2 and 3 compatibility utilities

# Install-time parameters
Provides:      python2-%{realname} = %{version}-%{release}
Obsoletes:     python2-%{realname} < %{version}-%{release}
Requires:      python(abi) = %{py_ver}

# Build-time parameters
%if ! 0%{?sles_version}
BuildArch:     noarch
%endif
BuildRequires: python-setuptools
BuildRequires: python-six
BuildRequires: %python3_pkg-setuptools
BuildRequires: %python3_pkg-six
BuildRoot:     %{_tmppath}/%{name}-root
Source:        %{realname}-%{version}%{?extraver}.%{srcext}

%description
Six is a Python 2 and 3 compatibility library. It provides utility functions for
smoothing over the differences between the Python versions with the goal of
writing Python code that is compatible on both Python versions. See the
documentation for more information on what is provided.

Six supports every Python version since 2.6. It is contained in only one Python
file, so it can be easily copied into your project. (The copyright and license
notice must be retained.)

%package -n python3-%{realname}
Group:         Development/Languages/Python
Summary:       Python 2 and 3 compatibility utilities

Requires:      python(abi) = %{py3_ver}
Provides:      %python3_pkg-%{realname} = %{version}-%{release}
Obsoletes:     %python3_pkg-%{realname} < %{version}-%{release}

%description -n python3-%{realname}
Six is a Python 2 and 3 compatibility library. It provides utility functions for
smoothing over the differences between the Python versions with the goal of
writing Python code that is compatible on both Python versions. See the
documentation for more information on what is provided.

Six supports every Python version since 2.6. It is contained in only one Python
file, so it can be easily copied into your project. (The copyright and license
notice must be retained.)

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -c -n python2
%setup -q -c -n python3 -D

%build
cd %{_builddir}/python2/%{realname}-%{version}%{?extraver}
python setup.py build
cd %{_builddir}/python3/%{realname}-%{version}%{?extraver}
%python3 setup.py build

%install
cd %{_builddir}/python2/%{realname}-%{version}%{?extraver}
python setup.py install --prefix=%{_prefix} --root=%{buildroot} -O2
cd %{_builddir}/python3/%{realname}-%{version}%{?extraver}
%python3 setup.py install --prefix=%{_prefix} --root=%{buildroot} -O2

%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

%files
%defattr(-,root,root)
%doc %{realname}-%{version}%{?extraver}/CHANGES
%doc %{realname}-%{version}%{?extraver}/LICENSE
%doc %{realname}-%{version}%{?extraver}/README.rst
%doc %{realname}-%{version}%{?extraver}/documentation/index.rst
%{python_sitelib}/%{realname}.*
%{python_sitelib}/%{realname}-%{version}*-py%{py_ver}.egg-info

%files -n python3-%{realname}
%defattr(-,root,root)
%doc %{realname}-%{version}%{?extraver}/CHANGES
%doc %{realname}-%{version}%{?extraver}/LICENSE
%doc %{realname}-%{version}%{?extraver}/README.rst
%doc %{realname}-%{version}%{?extraver}/documentation/index.rst
%{python3_sitelib}/%{realname}.*
%{python3_sitelib}/%{realname}-%{version}*-py%{py3_ver}.egg-info
%{python3_sitelib}/__pycache__/%{realname}.cpython-*.py?

%changelog