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