]>
Commit | Line | Data |
---|---|---|
4cdaa512 ER |
1 | # |
2 | # Conditional build: | |
3 | %bcond_without tests # do not perform "make test" | |
d328d943 | 4 | %bcond_without python3 # CPython 3.x module |
4cdaa512 | 5 | |
b81eefa5 | 6 | %define module template |
7170a7b1 ER |
7 | Summary: - |
8 | Summary(pl.UTF-8): - | |
3256a2f0 | 9 | # Name must match the python module/package name (as in 'import' statement) |
b81eefa5 | 10 | Name: python-%{module} |
7170a7b1 ER |
11 | Version: _ |
12 | Release: 0.1 | |
13 | License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here) | |
6177d217 | 14 | Group: Libraries/Python |
7170a7b1 ER |
15 | Source0: %{name}-%{version}.tar.gz |
16 | # Source0-md5: - | |
7170a7b1 | 17 | URL: - |
dbb3e196 | 18 | # remove BR: python-devel for 'noarch' packages. |
278010a4 | 19 | BuildRequires: python-devel |
dbb3e196 | 20 | BuildRequires: python-distribute |
0a48bf0d | 21 | BuildRequires: rpm-pythonprov |
7592d76f JB |
22 | # if py_postclean is used |
23 | BuildRequires: rpmbuild(macros) >= 1.219 | |
d328d943 ER |
24 | # when python3 present |
25 | BuildRequires: sed >= 4.0 | |
26 | %if %{with python3} | |
27 | BuildRequires: python3-devel | |
28 | BuildRequires: python3-distribute | |
29 | BuildRequires: python3-modules | |
30 | %endif | |
10305643 | 31 | #Requires: python-libs |
32 | Requires: python-modules | |
7170a7b1 ER |
33 | #BuildArch: noarch |
34 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
35 | ||
36 | %description | |
37 | ||
e6f4b058 | 38 | %description -l pl.UTF-8 |
39 | ||
d328d943 ER |
40 | %package apidoc |
41 | Summary: %{module} API documentation | |
42 | Summary(pl.UTF-8): Dokumentacja API %{module} | |
43 | Group: Documentation | |
44 | ||
45 | %description apidoc | |
46 | API documentation for %{module}. | |
47 | ||
48 | %description apidoc -l pl.UTF-8 | |
49 | Dokumentacja API %{module}. | |
50 | ||
7170a7b1 | 51 | %prep |
641675c1 | 52 | %setup -q -n %{module}-%{version} |
7170a7b1 | 53 | |
5a020810 | 54 | # fix #!/usr/bin/env python -> #!/usr/bin/python: |
cb13b64b | 55 | #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py |
5a020810 | 56 | |
d328d943 ER |
57 | %if %{with python3} |
58 | rm -rf build-3 | |
59 | set -- * | |
60 | install -d build-3 | |
61 | cp -a "$@" build-3 | |
62 | find build-3 -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|' | |
63 | %endif | |
64 | ||
7170a7b1 | 65 | %build |
d328d943 ER |
66 | %if %{with python2} |
67 | %{__python} setup.py build --build-base build-2 | |
68 | %endif | |
69 | %if %{with python3} | |
70 | %{__python3} setup.py build --build-base build-3 | |
71 | %endif | |
72 | ||
46094905 ER |
73 | # CC/CFLAGS is only for arch packages - remove on noarch packages |
74 | CC="%{__cc}" \ | |
75 | CFLAGS="%{rpmcflags}" \ | |
7592d76f | 76 | %{__python} setup.py build |
d328d943 ER |
77 | %{__python} setup.py \ |
78 | build -b build-2 | |
7170a7b1 | 79 | |
a4ec70eb ER |
80 | %{?with_tests:%{__python} setup.py test} |
81 | ||
d328d943 ER |
82 | %if %{with python3} |
83 | %{__python3} setup.py \ | |
84 | build -b build-3 | |
85 | ||
86 | %if %{with tests} | |
87 | %{__python3} setup.py test | |
88 | %endif | |
89 | %endif | |
90 | ||
91 | %if %{with doc} | |
92 | cd docs | |
93 | %{__make} -j1 html | |
94 | rm -rf _build/html/_sources | |
95 | %endif | |
96 | ||
7170a7b1 ER |
97 | %install |
98 | rm -rf $RPM_BUILD_ROOT | |
7592d76f | 99 | %{__python} setup.py install \ |
e7663425 | 100 | --skip-build \ |
7170a7b1 ER |
101 | --optimize=2 \ |
102 | --root=$RPM_BUILD_ROOT | |
103 | ||
d328d943 ER |
104 | %{__python} -- setup.py \ |
105 | build -b build-2 \ | |
106 | install \ | |
107 | --root=$RPM_BUILD_ROOT \ | |
108 | --optimize=2 | |
109 | ||
110 | %if %{with python2} | |
111 | %{__python} setup.py \ | |
112 | build --build-base build-2 \ | |
113 | install \ | |
114 | --root=$RPM_BUILD_ROOT \ | |
115 | --optimize=2 | |
116 | ||
117 | %py_postclean | |
118 | %endif | |
119 | ||
120 | %{__python3} -- setup.py \ | |
121 | build -b build-3 \ | |
122 | install \ | |
123 | --root=$RPM_BUILD_ROOT \ | |
124 | --optimize=2 | |
125 | ||
126 | %if %{with python3} | |
127 | %{__python3} setup.py \ | |
128 | build --build-base build-3 \ | |
129 | install \ | |
130 | --root=$RPM_BUILD_ROOT \ | |
131 | --optimize=2 | |
132 | %endif | |
133 | ||
8424aa58 ER |
134 | install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} |
135 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} | |
136 | ||
9a83d846 | 137 | # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages! |
e5a26a61 ER |
138 | %py_ocomp $RPM_BUILD_ROOT%{py_sitedir} |
139 | %py_comp $RPM_BUILD_ROOT%{py_sitedir} | |
140 | %py_postclean | |
141 | ||
7170a7b1 ER |
142 | %clean |
143 | rm -rf $RPM_BUILD_ROOT | |
144 | ||
7170a7b1 ER |
145 | %files |
146 | %defattr(644,root,root,755) | |
147 | %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO | |
9a83d846 | 148 | # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages! |
e5a26a61 ER |
149 | %{py_sitedir}/*.py[co] |
150 | %attr(755,root,root) %{py_sitedir}/*.so | |
ef0b62a1 | 151 | %if "%{py_ver}" > "2.4" |
47501bae | 152 | %{py_sitedir}/TEMPLATE-*.egg-info |
ef278603 | 153 | %endif |
8424aa58 | 154 | %{_examplesdir}/%{name}-%{version} |
d328d943 ER |
155 | |
156 | %if %{with python2} | |
157 | %files | |
158 | %defattr(644,root,root,755) | |
159 | %doc AUTHORS CHANGES LICENSE | |
160 | %{py_sitescriptdir}/%{module} | |
161 | %{py_sitescriptdir}/%{module}-%{version}-py*.egg-info | |
162 | %endif | |
163 | ||
164 | %if %{with python3} | |
165 | %files -n python3-%{module} | |
166 | %defattr(644,root,root,755) | |
167 | %doc AUTHORS CHANGES LICENSE | |
168 | %{py3_sitescriptdir}/%{module} | |
169 | %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info | |
170 | %endif | |
171 | ||
172 | %if %{with doc} | |
173 | %files apidoc | |
174 | %defattr(644,root,root,755) | |
175 | %doc docs/_build/html/* | |
176 | %endif |