]>
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 | |
d7036fa0 JB |
25 | # when using /usr/bin/env or other in-place substitutions |
26 | #BuildRequires: sed >= 4.0 | |
d328d943 | 27 | # when python3 present |
d328d943 ER |
28 | %if %{with python3} |
29 | BuildRequires: python3-devel | |
30 | BuildRequires: python3-distribute | |
31 | BuildRequires: python3-modules | |
32 | %endif | |
10305643 | 33 | #Requires: python-libs |
34 | Requires: python-modules | |
7170a7b1 ER |
35 | #BuildArch: noarch |
36 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
37 | ||
38 | %description | |
39 | ||
e6f4b058 | 40 | %description -l pl.UTF-8 |
41 | ||
0dd464e7 JK |
42 | %package -n python3-%{module} |
43 | Summary: - | |
44 | Summary(pl.UTF-8): - | |
45 | Group: Libraries/Python | |
46 | ||
47 | %description -n python3-%{module} | |
48 | ||
49 | %description -n python3-%{module} -l pl.UTF-8 | |
50 | ||
660096c2 | 51 | %package apidocs |
d328d943 ER |
52 | Summary: %{module} API documentation |
53 | Summary(pl.UTF-8): Dokumentacja API %{module} | |
54 | Group: Documentation | |
55 | ||
660096c2 | 56 | %description apidocs |
d328d943 ER |
57 | API documentation for %{module}. |
58 | ||
660096c2 | 59 | %description apidocs -l pl.UTF-8 |
d328d943 ER |
60 | Dokumentacja API %{module}. |
61 | ||
7170a7b1 | 62 | %prep |
641675c1 | 63 | %setup -q -n %{module}-%{version} |
7170a7b1 | 64 | |
5a020810 | 65 | # fix #!/usr/bin/env python -> #!/usr/bin/python: |
cb13b64b | 66 | #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py |
5a020810 | 67 | |
7170a7b1 | 68 | %build |
d328d943 | 69 | %if %{with python2} |
46094905 ER |
70 | # CC/CFLAGS is only for arch packages - remove on noarch packages |
71 | CC="%{__cc}" \ | |
72 | CFLAGS="%{rpmcflags}" \ | |
0dd464e7 JK |
73 | %{__python} setup.py build --build-base build-2 %{?with_tests:test} |
74 | %endif | |
a4ec70eb | 75 | |
d328d943 | 76 | %if %{with python3} |
0dd464e7 JK |
77 | # CC/CFLAGS is only for arch packages - remove on noarch packages |
78 | CC="%{__cc}" \ | |
79 | CFLAGS="%{rpmcflags}" \ | |
80 | %{__python3} setup.py build --build-base build-3 %{?with_tests:test} | |
d328d943 ER |
81 | %endif |
82 | ||
83 | %if %{with doc} | |
84 | cd docs | |
85 | %{__make} -j1 html | |
86 | rm -rf _build/html/_sources | |
87 | %endif | |
88 | ||
7170a7b1 ER |
89 | %install |
90 | rm -rf $RPM_BUILD_ROOT | |
d328d943 ER |
91 | |
92 | %if %{with python2} | |
93 | %{__python} setup.py \ | |
94 | build --build-base build-2 \ | |
0dd464e7 | 95 | install --skip-build \ |
d328d943 ER |
96 | --root=$RPM_BUILD_ROOT \ |
97 | --optimize=2 | |
98 | ||
99 | %py_postclean | |
100 | %endif | |
101 | ||
d328d943 ER |
102 | %if %{with python3} |
103 | %{__python3} setup.py \ | |
104 | build --build-base build-3 \ | |
0dd464e7 | 105 | install --skip-build \ |
d328d943 ER |
106 | --root=$RPM_BUILD_ROOT \ |
107 | --optimize=2 | |
108 | %endif | |
109 | ||
0dd464e7 JK |
110 | # in case there are examples provided |
111 | %if %{with python2} | |
112 | install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} | |
113 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} | |
114 | %endif | |
115 | %if %{with python3} | |
8424aa58 ER |
116 | install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} |
117 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} | |
0dd464e7 | 118 | find $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} -name '*.py' \ |
073f936a | 119 | | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' |
0dd464e7 | 120 | %endif |
8424aa58 | 121 | |
0dd464e7 JK |
122 | # when files are installed in other way that standard 'setup.py |
123 | # they need to be (re-)compiled | |
124 | ## change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages! | |
125 | #%%py_ocomp $RPM_BUILD_ROOT%{py_sitedir} | |
126 | #%%py_comp $RPM_BUILD_ROOT%{py_sitedir} | |
127 | #%%py_postclean | |
e5a26a61 | 128 | |
7170a7b1 ER |
129 | %clean |
130 | rm -rf $RPM_BUILD_ROOT | |
131 | ||
0dd464e7 | 132 | %if %{with python2} |
7170a7b1 ER |
133 | %files |
134 | %defattr(644,root,root,755) | |
135 | %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO | |
9a83d846 | 136 | # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages! |
e5a26a61 ER |
137 | %{py_sitedir}/*.py[co] |
138 | %attr(755,root,root) %{py_sitedir}/*.so | |
ef0b62a1 | 139 | %if "%{py_ver}" > "2.4" |
47501bae | 140 | %{py_sitedir}/TEMPLATE-*.egg-info |
ef278603 | 141 | %endif |
8424aa58 | 142 | %{_examplesdir}/%{name}-%{version} |
d328d943 ER |
143 | %endif |
144 | ||
145 | %if %{with python3} | |
146 | %files -n python3-%{module} | |
147 | %defattr(644,root,root,755) | |
148 | %doc AUTHORS CHANGES LICENSE | |
149 | %{py3_sitescriptdir}/%{module} | |
150 | %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info | |
0dd464e7 | 151 | %{_examplesdir}/%{python3}-%{module}-%{version} |
d328d943 ER |
152 | %endif |
153 | ||
154 | %if %{with doc} | |
660096c2 | 155 | %files apidocs |
d328d943 ER |
156 | %defattr(644,root,root,755) |
157 | %doc docs/_build/html/* | |
158 | %endif |