b849c8f
%if 0%{?rhel} && 0%{?rhel} <= 6
b849c8f
%{!?__python2:        %global __python2 /usr/bin/python2}
b849c8f
%{!?python2_sitelib:  %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
b849c8f
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
b849c8f
%endif
b849c8f
b849c8f
%if 0%{?fedora}
b849c8f
%global with_python3 1
b849c8f
%endif
b849c8f
b849c8f
%global modname pypng
b849c8f
b849c8f
Name:               python-pypng
3908f37
Version:            0.0.18
3908f37
Release:            1%{?dist}
b849c8f
Summary:            Pure Python PNG image encoder/decoder
b849c8f
b849c8f
Group:              Development/Libraries
b849c8f
License:            MIT
b849c8f
URL:                http://pypi.python.org/pypi/pypng
b849c8f
Source0:            https://github.com/drj11/%{modname}/archive/%{modname}-%{version}.tar.gz
b849c8f
b849c8f
BuildArch:          noarch
b849c8f
b849c8f
BuildRequires:      python2-devel
b849c8f
BuildRequires:      python-nose
b849c8f
b849c8f
%if 0%{?with_python3}
b849c8f
BuildRequires:      python3-devel
b849c8f
BuildRequires:      python3-nose
b849c8f
BuildRequires:      python-tools
b849c8f
%endif
b849c8f
b849c8f
%description
b849c8f
PyPNG allows PNG image files to be read and written using pure Python.
b849c8f
b849c8f
It's available from github.com https://github.com/drj11/pypng
b849c8f
b849c8f
Documentation is kindly hosted by PyPI http://pythonhosted.org/pypng/
b849c8f
b849c8f
%if 0%{?with_python3}
b849c8f
%package -n python3-pypng
b849c8f
Summary:            Pure Python PNG image encoder/decoder
b849c8f
Group:              Development/Libraries
b849c8f
b849c8f
%description -n python3-pypng
b849c8f
PyPNG allows PNG image files to be read and written using pure Python.
b849c8f
b849c8f
It's available from github.com https://github.com/drj11/pypng
b849c8f
b849c8f
Documentation is kindly hosted by PyPI http://pythonhosted.org/pypng/
b849c8f
%endif
b849c8f
b849c8f
%prep
b849c8f
%setup -q -n %{modname}-%{modname}-%{version}
b849c8f
b849c8f
# Remove bundled egg-info in case it exists
b849c8f
rm -rf %{modname}.egg-info
b849c8f
b849c8f
# Remove the shebang from the main lib
b849c8f
lib=code/png.py
b849c8f
sed '1{\@^#!/usr/bin/env python@d}' $lib > $lib.new &&
b849c8f
touch -r $lib $lib.new &&
b849c8f
mv $lib.new $lib
b849c8f
b849c8f
%if 0%{?with_python3}
b849c8f
rm -rf %{py3dir}
b849c8f
cp -a . %{py3dir}
b849c8f
2to3 --write --nobackups %{py3dir}
b849c8f
%endif
b849c8f
b849c8f
%build
b849c8f
%{__python2} setup.py build
b849c8f
%if 0%{?with_python3}
b849c8f
pushd %{py3dir}
b849c8f
%{__python3} setup.py build
b849c8f
popd
b849c8f
%endif
b849c8f
b849c8f
%install
b849c8f
%if 0%{?with_python3}
b849c8f
pushd %{py3dir}
b849c8f
%{__python3} setup.py install -O1 --skip-build --root=%{buildroot}
b849c8f
popd
b849c8f
%endif
b849c8f
%{__python2} setup.py install -O1 --skip-build --root=%{buildroot}
b849c8f
b849c8f
%check
b849c8f
nosetests code/png.py
b849c8f
%if 0%{?with_python3}
b849c8f
pushd %{py3dir}
b849c8f
nosetests-%{python3_version} code/png.py
b849c8f
popd
b849c8f
%endif
b849c8f
b849c8f
%files
b849c8f
%doc README.txt LICENCE
b849c8f
%{python2_sitelib}/png.py*
b849c8f
%{python2_sitelib}/%{modname}-%{version}*
b849c8f
b849c8f
%if 0%{?with_python3}
b849c8f
%files -n python3-pypng
b849c8f
%doc README.txt LICENCE
b849c8f
%{python3_sitelib}/png.py*
b849c8f
%{python3_sitelib}/__pycache__/png*
b849c8f
%{python3_sitelib}/%{modname}-%{version}-*
b849c8f
%endif
b849c8f
b849c8f
%changelog
3908f37
* Sat Aug 01 2015 Ralph Bean <rbean@redhat.com> - 0.0.18-1
3908f37
- new version
3908f37
b6358da
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0.17-2
b6358da
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
b6358da
e8a135a
* Tue May 12 2015 Ralph Bean <rbean@redhat.com> - 0.0.17-1
e8a135a
- new version
e8a135a
124be56
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0.16-3
124be56
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
124be56
c2492ea
* Wed May 28 2014 Kalev Lember <kalevlember@gmail.com> - 0.0.16-2
c2492ea
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4
c2492ea
b849c8f
* Fri May 09 2014 Ralph Bean <rbean@redhat.com> - 0.0.16-1
b849c8f
- initial package for Fedora