Blob Blame History Raw
%global mod_name webassets
%if 0%{?fedora}
%global with_python3 1
%else
%global with_python3 0
%endif

Name:           python-webassets
Version:        0.9
Release:        5%{?dist}
Summary:        Media asset management for python
Group:          Development/Libraries
License:        BSD
URL:            http://github.com/miracle2k/%{mod_name}
Source0:        https://pypi.python.org/packages/source/w/%{mod_name}/%{mod_name}-%{version}.tar.gz
# These patches are all merged upstream in 0.10 or later.
# Backports are tracked here:
# https://github.com/danc86/webassets/commits/0.9-stable
Patch1:         0001-escape-JS-string-literals-correctly-in-JST-filter.patch
Patch2:         0002-fixed-webassets-issue-286-and-switch-I-O-to-binary-m.patch
Patch3:         0003-added-unit-test-for-fix-to-issue-286.patch
Patch4:         0004-Encoding-decoding-of-files.patch
Patch5:         0005-Merge-graffic-unicode-python2-for-the-unicode-tests.patch
Patch6:         0006-Avoid-an-extra-stat-call-on-cache-lookups.patch
Patch7:         0007-Create-cache-entries-atomically-in-FilesystemCache.patch
Patch8:         0008-Support-files-lists-or-tuples-in-Jinja2-assets-block.patch
Patch9:         0009-Fix-cssrewrite-filter-dealing-with-hostnames.patch
Patch10:        0010-Preserve-exit-status.patch
Patch11:        0011-Make-it-possible-to-customize-jinja-extension-in-Jin.patch
Patch12:        0012-Update-some-test-filter-outputs.patch
Patch13:        0013-Fix-closing-temporary-files.patch
# https://github.com/miracle2k/webassets/pull/372
Patch14:        0014-support-jsmin.py-from-v8.patch
BuildArch:      noarch
BuildRequires:  python-devel
BuildRequires:  python-setuptools
Requires:       python-setuptools
# test requirements
BuildRequires:  python-nose
BuildRequires:  python-mock
# v8 is just for jsmin.py
BuildRequires:  v8
# skipping pyscss tests for now since 1.2+ is intentionally not supported
#BuildRequires:  python-scss
%if !0%{?epel}
BuildRequires:  /usr/bin/sass
BuildRequires:  /usr/bin/compass
BuildRequires:  python-cssutils
BuildRequires:  python-slimit
%endif
BuildRequires:  python-cssmin
BuildRequires:  /usr/bin/uglifyjs
BuildRequires:  /usr/bin/lessc
BuildRequires:  /usr/bin/coffee
%if 0%{?with_python3}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
Requires:       python3-setuptools
# test requirements
BuildRequires:  python3-nose
BuildRequires:  python3-mock
# these are not ported to Python 3 yet
#BuildRequires:  python3-slimit
#BuildRequires:  python3-cssutils
#BuildRequires:  python3-scss
#BuildRequires:  python3-cssmin
%endif


%description
Merges, minifies and compresses Javascript and CSS files, 
supporting a variety of different filters, including YUI, 
jsmin, jspacker or CSS tidy. Also supports URL rewriting in CSS files.

%if 0%{?with_python3}
%package -n python3-webassets
Summary:        Media asset management for python

%description -n python3-webassets
Merges, minifies and compresses Javascript and CSS files, 
supporting a variety of different filters, including YUI, 
jsmin, jspacker or CSS tidy. Also supports URL rewriting in CSS files.
%endif


%prep
%setup -q -n %{mod_name}-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
sed -i "s|\r||g" README.rst
sed -i "s|\r||g" docs/index.rst
sed -i "s|\r||g" docs/conf.py
sed -i "s|\r||g" docs/builtin_filters.rst
sed -i "s|\r||g" docs/Makefile
sed -i "s|\r||g" docs/make.bat
sed -i "s|\r||g" docs/faq.rst

%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif

%build
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build

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

%check
export LC_ALL=en_US.utf8
nosetests

%if 0%{?with_python3}
pushd %{py3dir}
nosetests-%{python3_version}
popd
%endif

%install
%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
sed -i -e '/^#!\//, 1d' $RPM_BUILD_ROOT%{python_sitelib}/%{mod_name}/filter/rjsmin/rjsmin.py
 
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
sed -i -e '/^#!\//, 1d' $RPM_BUILD_ROOT%{python3_sitelib}/%{mod_name}/filter/rjsmin/rjsmin.py
popd
%endif

%files
%doc docs/ README.rst CHANGES LICENSE PKG-INFO
%{_bindir}/%{mod_name}
%{python_sitelib}/*.egg-info/
%{python_sitelib}/%{mod_name}/

%if 0%{?with_python3}
%files -n python3-webassets
%doc docs/ README.rst CHANGES LICENSE PKG-INFO
%{_bindir}/%{mod_name}
%{python3_sitelib}/*.egg-info/
%{python3_sitelib}/%{mod_name}/
%endif

%changelog
* Wed Dec 17 2014 Dan Callaghan <dcallagh@redhat.com> - 0.9-5
- updated patches to match upstream commits merged in 0.10
- backported some more API-compatible fixes and enhancements from 0.10
- unit tests are run in %%check

* Mon Nov 10 2014 Dan Callaghan <dcallagh@redhat.com> - 0.9-4
- RHBZ#1142524 escape backslashes in string literals in JST filter
- RHBZ#1142525 fix UnicodeDecodeError for non-ASCII files
- fix cache corruption when shared between multiple writers

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

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

* Thu Nov 14 2013 Praveen Kumar <kumarpraveen.nitdgp@gmail.com> 0.9-1
- Updated to new source and added python3 support 

* Tue Sep 24 2013 Praveen Kumar <kumarpraveen.nitdgp@gmail.com> - 0.8-3
- Added python-setuptools as requires. 

* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Mon Jul 1 2013 Praveen Kumar <kumarpraveen.nitdgp@gmail.com> - 0.8-1
- New Release 

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Wed Aug  8 2012 Tom Callaway <spot@fedoraproject.org> - 0.7.1-1
- 0.7.1 (cleaned out jsmin.py)

* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Sat May 12 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.7-1
- New release

* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Thu Jul 21 2011 Praveen Kumar <kumarpraveen.nitdgp@gmail.com> - 0.5-1
- Initial RPM release