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