]>
Commit | Line | Data |
---|---|---|
9565b208 JB |
1 | # |
2 | # Conditional build: | |
e1cf6bb3 JB |
3 | %bcond_without python2 # CPython 2.x module |
4 | %bcond_without python3 # CPython 3.x module | |
5 | %bcond_without tests # unit tests | |
6 | %bcond_with tests_net # unit tests using network | |
9565b208 | 7 | |
326d111c | 8 | %define module cssutils |
11143ddf | 9 | %define encutils_ver 0.9.8 |
9565b208 JB |
10 | Summary: A CSS Cascading Style Sheets library for Python 2 |
11 | Summary(pl.UTF-8): Biblioteka CSS (Cascading Style Sheets) dla Pythona 2 | |
326d111c | 12 | Name: python-%{module} |
9565b208 | 13 | Version: 1.0.2 |
5f9a08ae | 14 | Release: 9 |
2c1855bc | 15 | Epoch: 1 |
6d86ddd7 | 16 | License: LGPL v3+ |
326d111c | 17 | Group: Libraries/Python |
94d72300 | 18 | Source0: https://files.pythonhosted.org/packages/source/c/cssutils/%{module}-%{version}.tar.gz |
9565b208 JB |
19 | # Source0-md5: dc66d96c2d78f1687f59ac412fe9d318 |
20 | Patch0: %{name}-tests.patch | |
21 | Patch1: %{name}-mock.patch | |
326d111c | 22 | URL: http://cthedot.de/cssutils/ |
9565b208 | 23 | %if %{with python2} |
326d111c | 24 | BuildRequires: python-devel >= 1:2.5 |
9565b208 | 25 | %{?with_tests:BuildRequires: python-mock} |
52e73fa6 | 26 | BuildRequires: python-setuptools |
9565b208 JB |
27 | %endif |
28 | %if %{with python3} | |
29 | BuildRequires: python3-2to3 >= 1:3.2 | |
30 | BuildRequires: python3-devel >= 1:3.2 | |
31 | BuildRequires: python3-setuptools | |
32 | %endif | |
ce56d868 | 33 | BuildRequires: rpm-pythonprov |
9565b208 JB |
34 | BuildRequires: rpmbuild(macros) >= 1.714 |
35 | Requires: python-modules >= 1:2.5 | |
6d86ddd7 AF |
36 | Provides: python-encutils = %{encutils_ver} |
37 | Obsoletes: python-encutils < %{encutils_ver} | |
fb9c2bb1 | 38 | BuildArch: noarch |
326d111c AF |
39 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
40 | ||
41 | %description | |
42 | A Python package to parse and build CSS Cascading Style Sheets. Partly | |
ce56d868 JB |
43 | implements the DOM Level 2 Stylesheets and DOM Level 2 CSS interfaces. |
44 | ||
fc31ca58 | 45 | %description -l pl.UTF-8 |
ce56d868 | 46 | Pakiet Pythona do analizy i tworzenia CSS (Cascading Style Sheets). |
fc31ca58 | 47 | Częściowo implementuje interfejsy DOM Level 2 Stylesheets oraz DOM |
ce56d868 | 48 | Level 2 CSS. |
326d111c | 49 | |
9565b208 JB |
50 | %package -n python3-%{module} |
51 | Summary: A CSS Cascading Style Sheets library for Python 3 | |
52 | Summary(pl.UTF-8): Biblioteka CSS (Cascading Style Sheets) dla Pythona 3 | |
53 | Group: Libraries/Python | |
54 | Requires: python3-modules >= 1:3.2 | |
55 | ||
56 | %description -n python3-%{module} | |
57 | A Python package to parse and build CSS Cascading Style Sheets. Partly | |
58 | implements the DOM Level 2 Stylesheets and DOM Level 2 CSS interfaces. | |
59 | ||
60 | %description -n python3-%{module} -l pl.UTF-8 | |
61 | Pakiet Pythona do analizy i tworzenia CSS (Cascading Style Sheets). | |
62 | Częściowo implementuje interfejsy DOM Level 2 Stylesheets oraz DOM | |
63 | Level 2 CSS. | |
64 | ||
326d111c | 65 | %prep |
ab760d3b | 66 | %setup -q -n %{module}-%{version} |
9565b208 JB |
67 | %patch0 -p1 |
68 | %patch1 -p1 | |
69 | ||
6d86ddd7 AF |
70 | eval $(PYTHONPATH=src python -c "from encutils import VERSION;print 'VERSION=%%s' %% VERSION") |
71 | if [ $VERSION != %{encutils_ver} ]; then | |
72 | echo "Please set encutils_ver to $VERSION" | |
73 | exit 1 | |
74 | fi | |
326d111c | 75 | |
e1cf6bb3 JB |
76 | %if %{without tests_net} |
77 | %{__sed} -i -e 's/def test_parseUrl/def skip_parseUrl/' src/cssutils/tests/test_parse.py | |
78 | %{__sed} -i -e 's/def test_handlers/def skip_handlers/' src/cssutils/tests/test_errorhandler.py | |
79 | %endif | |
80 | ||
326d111c | 81 | %build |
9565b208 | 82 | %if %{with python2} |
7737135b | 83 | %py_build |
326d111c | 84 | |
9565b208 JB |
85 | %if %{with tests} |
86 | %{__python} -m unittest discover -t build-2/lib -s build-2/lib/cssutils/tests | |
87 | %endif | |
88 | %endif | |
89 | ||
90 | %if %{with python3} | |
91 | %py3_build | |
92 | ||
93 | %if %{with tests} | |
94 | %{__python3} -m unittest discover -t build-3/lib -s build-3/lib/cssutils/tests | |
95 | %endif | |
96 | %endif | |
97 | ||
326d111c AF |
98 | %install |
99 | rm -rf $RPM_BUILD_ROOT | |
100 | ||
9565b208 JB |
101 | %if %{with python3} |
102 | %py3_install | |
103 | ||
104 | for f in csscapture csscombine cssparse ; do | |
105 | %{__mv} $RPM_BUILD_ROOT%{_bindir}/$f $RPM_BUILD_ROOT%{_bindir}/${f}-3 | |
106 | done | |
107 | ||
108 | %{__rm} -r $RPM_BUILD_ROOT%{py3_sitescriptdir}/cssutils/tests | |
109 | %endif | |
110 | ||
111 | %if %{with python2} | |
112 | %py_install | |
113 | ||
114 | for f in csscapture csscombine cssparse ; do | |
115 | %{__mv} $RPM_BUILD_ROOT%{_bindir}/$f $RPM_BUILD_ROOT%{_bindir}/${f}-2 | |
116 | ln -sf ${f}-2 $RPM_BUILD_ROOT%{_bindir}/$f | |
117 | done | |
326d111c | 118 | |
e2bea7fd | 119 | %py_postclean |
9565b208 JB |
120 | %{__rm} -r $RPM_BUILD_ROOT%{py_sitescriptdir}/cssutils/tests |
121 | %endif | |
e2bea7fd | 122 | |
326d111c AF |
123 | %clean |
124 | rm -rf $RPM_BUILD_ROOT | |
125 | ||
9565b208 | 126 | %if %{with python2} |
326d111c AF |
127 | %files |
128 | %defattr(644,root,root,755) | |
129 | %doc README.txt | |
e2bea7fd | 130 | %attr(755,root,root) %{_bindir}/csscapture |
131 | %attr(755,root,root) %{_bindir}/csscombine | |
ce56d868 | 132 | %attr(755,root,root) %{_bindir}/cssparse |
9565b208 JB |
133 | %attr(755,root,root) %{_bindir}/csscapture-2 |
134 | %attr(755,root,root) %{_bindir}/csscombine-2 | |
135 | %attr(755,root,root) %{_bindir}/cssparse-2 | |
136 | %{py_sitescriptdir}/cssutils | |
137 | %{py_sitescriptdir}/encutils | |
138 | %{py_sitescriptdir}/cssutils-%{version}-py*.egg-info | |
139 | %endif | |
140 | ||
141 | %if %{with python3} | |
142 | %files -n python3-%{module} | |
143 | %defattr(644,root,root,755) | |
144 | %attr(755,root,root) %{_bindir}/csscapture-3 | |
145 | %attr(755,root,root) %{_bindir}/csscombine-3 | |
146 | %attr(755,root,root) %{_bindir}/cssparse-3 | |
147 | %{py3_sitescriptdir}/cssutils | |
148 | %{py3_sitescriptdir}/encutils | |
149 | %{py3_sitescriptdir}/cssutils-%{version}-py*.egg-info | |
150 | %endif |