Blob Blame History Raw
%if 0%{?rhel} && 0%{?rhel} <= 6
%{!?__python2:        %global __python2 /usr/bin/python2}
%{!?python2_sitelib:  %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%endif

%if 0%{?fedora}
%global with_python3 1
%endif

%global modname pypng

Name:               python-pypng
Version:            0.0.18
Release:            1%{?dist}
Summary:            Pure Python PNG image encoder/decoder

Group:              Development/Libraries
License:            MIT
URL:                http://pypi.python.org/pypi/pypng
Source0:            https://github.com/drj11/%{modname}/archive/%{modname}-%{version}.tar.gz

BuildArch:          noarch

BuildRequires:      python2-devel
BuildRequires:      python-nose

%if 0%{?with_python3}
BuildRequires:      python3-devel
BuildRequires:      python3-nose
BuildRequires:      python-tools
%endif

%description
PyPNG allows PNG image files to be read and written using pure Python.

It's available from github.com https://github.com/drj11/pypng

Documentation is kindly hosted by PyPI http://pythonhosted.org/pypng/

%if 0%{?with_python3}
%package -n python3-pypng
Summary:            Pure Python PNG image encoder/decoder
Group:              Development/Libraries

%description -n python3-pypng
PyPNG allows PNG image files to be read and written using pure Python.

It's available from github.com https://github.com/drj11/pypng

Documentation is kindly hosted by PyPI http://pythonhosted.org/pypng/
%endif

%prep
%setup -q -n %{modname}-%{modname}-%{version}

# Remove bundled egg-info in case it exists
rm -rf %{modname}.egg-info

# Remove the shebang from the main lib
lib=code/png.py
sed '1{\@^#!/usr/bin/env python@d}' $lib > $lib.new &&
touch -r $lib $lib.new &&
mv $lib.new $lib

%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
2to3 --write --nobackups %{py3dir}
%endif

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

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

%check
nosetests code/png.py
%if 0%{?with_python3}
pushd %{py3dir}
nosetests-%{python3_version} code/png.py
popd
%endif

%files
%doc README.txt LICENCE
%{python2_sitelib}/png.py*
%{python2_sitelib}/%{modname}-%{version}*

%if 0%{?with_python3}
%files -n python3-pypng
%doc README.txt LICENCE
%{python3_sitelib}/png.py*
%{python3_sitelib}/__pycache__/png*
%{python3_sitelib}/%{modname}-%{version}-*
%endif

%changelog
* Sat Aug 01 2015 Ralph Bean <rbean@redhat.com> - 0.0.18-1
- new version

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0.17-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Tue May 12 2015 Ralph Bean <rbean@redhat.com> - 0.0.17-1
- new version

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0.16-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Wed May 28 2014 Kalev Lember <kalevlember@gmail.com> - 0.0.16-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4

* Fri May 09 2014 Ralph Bean <rbean@redhat.com> - 0.0.16-1
- initial package for Fedora