%if 0%{?rhel} && 0%{?rhel} <= 5 %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} %endif %if 0%{?fedora} > 12 %global with_python3 1 %endif %global srcname slimit Name: python-slimit Version: 0.8.1 Release: 1%{?dist} Summary: JavaScript minifier written in Python Group: Development/Languages License: MIT URL: http://slimit.org/ Source0: http://pypi.python.org/packages/source/s/%{srcname}/%{srcname}-%{version}.zip BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch BuildRequires: python2-devel BuildRequires: python-setuptools # Required for running tests BuildRequires: python-ply >= 3.4 Requires: python2 Requires: python-ply >= 3.4 Requires: python-setuptools # Python 2.7+ includes an ordered dictionary in its collection module %if 0%{?rhel} && 0%{?rhel} <= 6 BuildRequires: python-odict Requires: python-odict %endif %if 0%{?with_python3} BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-ply >= 3.4 %endif %description SlimIt is a JavaScript minifier written in Python. It compiles JavaScript into more compact code so that it downloads and runs faster. SlimIt also provides a library that includes a JavaScript parser, lexer, pretty printer and a tree visitor. %if 0%{?with_python3} %package -n python3-slimit Summary: JavaScript minifier written in Python Group: Development/Languages Requires: python3 Requires: python3-setuptools Requires: python3-ply >= 3.4 %description -n python3-slimit SlimIt is a JavaScript minifier written in Python. It compiles JavaScript into more compact code so that it downloads and runs faster. SlimIt also provides a library that includes a JavaScript parser, lexer, pretty printer and a tree visitor. %endif %prep %setup -qc -n %{srcname}-%{version} rm -rf src/%{srcname}.egg-info # Create python 2 build directory mv %{srcname}-%{version} python2 pushd python2 # Copy docs to top directory cp -pr CHANGES README.rst ../ popd %if 0%{?with_python3} cp -a python2 python3 find python3 -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|' %endif # with_python3 find python2 -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python2}|' %clean rm -rf $RPM_BUILD_ROOT %build pushd python2 CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup.py build popd %if 0%{?with_python3} pushd python3 CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build popd %endif # with_python3 %install %if 0%{?with_python3} %if (0%{?fedora} && %{?fedora} <= 22) # On Fedora 22 and older, python 2 is the default interpreter # So build python3 first and /usr/bin/slimit will be replaced pushd python3 %{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT chmod a+x $RPM_BUILD_ROOT/%{_bindir}/%{srcname} rm -rf %{buildroot}%{python3_sitelib}/%{srcname}/tests popd %endif #fedora 22 and older %endif #with_python3 pushd python2 %{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT chmod a+x $RPM_BUILD_ROOT/%{_bindir}/%{srcname} rm -rf %{buildroot}%{python2_sitelib}/%{srcname}/tests popd %if 0%{?with_python3} %if (0%{?fedora} && %{?fedora} >= 23) # On Fedora 23 and newer, python 3 is the default interpreter # So build python2 first and /usr/bin/slimit will be replaced pushd python3 %{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT chmod a+x $RPM_BUILD_ROOT/%{_bindir}/%{srcname} rm -rf %{buildroot}%{python3_sitelib}/%{srcname}/tests popd %endif #fedora 22 and older %endif #with_python3 %check pushd python2 %{__python2} setup.py test -m slimit.tests.test_lexer %{__python2} setup.py test -m slimit.tests.test_nodevisitor popd # Tests do not run in python3 right now. Fix later. #%if 0%{?with_python3} #pushd python3 #%{__python3} setup.py test -m slimit.tests.test_lexer #%{__python3} setup.py test -m slimit.tests.test_nodevisitor #popd #%endif %files %doc CHANGES README.rst %if (0%{?fedora} && 0%{?fedora} <= 22) || 0%{?rhel} %{_bindir}/slimit %endif %{python2_sitelib}/%{srcname}/ %{python2_sitelib}/%{srcname}-%{version}*.egg-info %if 0%{?with_python3} %files -n python3-slimit %doc CHANGES README.rst %if 0%{?fedora} && 0%{?fedora} >= 23 %{_bindir}/slimit %endif %{python3_sitelib}/%{srcname}/ %{python3_sitelib}/%{srcname}-%{version}*.egg-info %endif %changelog * Tue Jun 30 2015 Stephen Gallagher 0.8.1-1 - Update to latest upstream release 0.8.1 - https://pypi.python.org/pypi/slimit/0.8.1 - Add python3 version * Thu Jun 18 2015 Fedora Release Engineering - 0.7.4-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild * Fri Mar 06 2015 Stephen Gallagher 0.7.4-7 - SlimIt requires setuptools at runtime * Sat Jun 07 2014 Fedora Release Engineering - 0.7.4-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild * Sun Aug 04 2013 Fedora Release Engineering - 0.7.4-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild * Thu Feb 14 2013 Fedora Release Engineering - 0.7.4-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild * Thu Oct 04 2012 Stephen Gallagher - 0.7.4-3 - Add %%{srcname} * Thu Oct 04 2012 Stephen Gallagher - 0.7.4-2 - Spec file changes from package review - Added support for EPEL - Run tests in %%check - Add %%clean * Wed Oct 03 2012 Stephen Gallagher - 0.7.4-1 - Initial release