File python-rarfile.spec of Package python-rarfile

%if 0%{?fedora} > 12
%global with_python3 1
%else
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())")}
%endif

%global scrname rarfile

Name:           python-%{scrname}
Version:        2.7
Release:        1%{?dist}
Summary:        A RAR archive reader for Python

License:        ISC
URL:            https://github.com/markokr/rarfile
Source0:        https://pypi.python.org/packages/source/r/%{scrname}/%{scrname}-%{version}.tar.gz
Buildarch:      noarch

BuildRequires:  python2-devel
BuildRequires:  python-setuptools

%if 0%{?with_python3}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
%endif

%description
This is Python module for RAR archive reading. The interface is made as
zipfile like as possible.

%if 0%{?with_python3}
%package -n python3-%{scrname}
Summary:        A RAR archive reader for Python
BuildArch:      noarch

%description -n python3-%{scrname}
This is Python module for RAR archive reading. The interface is made as
zipfile like as possible.
%endif

%prep
%setup -q -n %{scrname}-%{version}
find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python2}|'
rm -rf %{srcname}.egg-info
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif

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

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

%files
%doc README.rst
%license LICENSE
%{python2_sitelib}/%{scrname}.py*
%{python2_sitelib}/%{scrname}*.egg-info

%if 0%{?with_python3}
%files -n python3-%{scrname}
%doc README.rst
%license LICENSE
%{python3_sitelib}/%{scrname}.py*
%{python3_sitelib}/%{scrname}*.egg-info
%{python3_sitelib}/__pycache__/%{scrname}*
%endif # with_python3

%changelog
* Sun Mar 15 2015 Fabian Affolter <mail@fabian-affolter.ch> - 2.7-1
- Initial package
openSUSE Build Service is sponsored by