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