%global with_python3 1 %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} Name: python-pypng Version: 0.0.16 Release: 1.z1%{?dist} Summary: Python PNG encoder/decoder License: MIT URL: https://github.com/drj11/pypng Source0: https://github.com/drj11/pypng/archive/pypng-0.0.16.zip BuildArch: noarch BuildRequires: python2-devel %if 0%{?with_python3} BuildRequires: python3-devel # Without requiring python3-setuptools, setup.py throws a warning about # missing 2to3, but completes the build. Resulting package is empty though. BuildRequires: python3-setuptools %endif %description A pure Python module to decode (read) and encode (write) PNG image files. %if 0%{?with_python3} %package -n python3-pypng Summary: Python 3 PNG encoder/decoder %description -n python3-pypng A Python 3 module to decode (read) and encode (write) PNG image files. %endif %prep %setup -q -n pypng-pypng-%{version} %if 0%{?with_python3} # The {py3dir} is a convenience built-in that Fedora provides in F13 rm -rf %{py3dir} cp -a . %{py3dir} find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!/usr/bin/env python|#!%{__python3}|' %endif %build # Remove CFLAGS=... for noarch packages (unneeded) CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build %if 0%{?with_python3} pushd %{py3dir} CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build popd %endif %install rm -rf $RPM_BUILD_ROOT %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT # Fortunately our packages are fully co-existing %if 0%{?with_python3} pushd %{py3dir} %{__python3} setup.py install --skip-build --root $RPM_BUILD_ROOT popd %endif %files %doc README.txt %{python_sitelib}/* %if 0%{?with_python3} %files -n python3-pypng %doc README.txt %{python3_sitelib}/* %endif %changelog * Sat Jan 04 2014 Pete Zaitcev - 0.0.16-1.z1 - Add Python 3 * Mon Oct 14 2013 Matthew Miller - 0.0.16-1 - update to 0.0.16 * Thu Apr 05 2012 Matthew Miller - 0.0.12-1 - initial package