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