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