]>
Commit | Line | Data |
---|---|---|
4e897198 | 1 | # |
367df2cb | 2 | # This is template for python2/python3 extension modules (including compiled C code) |
4e897198 | 3 | # use template-specs/python.spec for pure python packages |
367df2cb | 4 | # use template-specs/python3-ext.spec for python3 only packages |
4e897198 JK |
5 | # |
6 | # Conditional build: | |
7 | %bcond_without doc # don't build doc | |
8 | %bcond_without tests # do not perform "make test" | |
9 | %bcond_without python2 # CPython 2.x module | |
10 | %bcond_without python3 # CPython 3.x module | |
11 | ||
12 | %define module template | |
13 | Summary: - | |
14 | Summary(pl.UTF-8): - | |
d1ab9a90 | 15 | # Name must match the python module/package name (as on pypi or in 'import' statement) |
4e897198 JK |
16 | Name: python-%{module} |
17 | Version: _ | |
18 | Release: 0.1 | |
19 | License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here) | |
20 | Group: Libraries/Python | |
8329d0fc JB |
21 | # if pypi: |
22 | #Source0Download: https://pypi.org/simple/MODULE/ | |
23 | Source0: https://files.pythonhosted.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz | |
4e897198 | 24 | # Source0-md5: - |
8329d0fc | 25 | #URL: https://pypi.org/project/MODULE/ |
4e897198 | 26 | URL: - |
4e897198 | 27 | %if %{with python2} |
367df2cb | 28 | BuildRequires: python-devel >= 1:2.5 |
4e897198 | 29 | #BuildRequires: python-setuptools |
367df2cb JB |
30 | %if %{with tests} |
31 | #BuildRequires: python- | |
32 | %endif | |
4e897198 JK |
33 | %endif |
34 | %if %{with python3} | |
367df2cb | 35 | BuildRequires: python3-devel >= 1:3.2 |
4e897198 | 36 | #BuildRequires: python3-setuptools |
367df2cb JB |
37 | %if %{with tests} |
38 | #BuildRequires: python3- | |
4e897198 | 39 | %endif |
367df2cb JB |
40 | %endif |
41 | BuildRequires: rpm-pythonprov | |
42 | # for the py_build, py_install macros | |
43 | BuildRequires: rpmbuild(macros) >= 1.714 | |
4e897198 JK |
44 | # when using /usr/bin/env or other in-place substitutions |
45 | #BuildRequires: sed >= 4.0 | |
367df2cb JB |
46 | %if %{with doc} |
47 | BuildRequires: sphinx-pdg # -2 or -3 | |
48 | %endif | |
4e897198 | 49 | # replace with other requires if defined in setup.py |
367df2cb | 50 | Requires: python-modules >= 1:2.5 |
4e897198 JK |
51 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
52 | ||
53 | %description | |
54 | ||
55 | %description -l pl.UTF-8 | |
56 | ||
57 | %package -n python3-%{module} | |
58 | Summary: - | |
59 | Summary(pl.UTF-8): - | |
60 | Group: Libraries/Python | |
367df2cb | 61 | Requires: python3-modules >= 1:3.2 |
4e897198 JK |
62 | |
63 | %description -n python3-%{module} | |
64 | ||
65 | %description -n python3-%{module} -l pl.UTF-8 | |
66 | ||
67 | %package apidocs | |
68 | Summary: %{module} API documentation | |
69 | Summary(pl.UTF-8): Dokumentacja API %{module} | |
70 | Group: Documentation | |
0e3a4294 | 71 | %if "%{_rpmversion}" >= "4.6" |
8329d0fc JB |
72 | BuildArch: noarch |
73 | %endif | |
4e897198 JK |
74 | |
75 | %description apidocs | |
76 | API documentation for %{module}. | |
77 | ||
78 | %description apidocs -l pl.UTF-8 | |
79 | Dokumentacja API %{module}. | |
80 | ||
81 | %prep | |
82 | %setup -q -n %{module}-%{version} | |
83 | ||
84 | # fix #!/usr/bin/env python -> #!/usr/bin/python: | |
85 | #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py | |
86 | ||
87 | %build | |
88 | %if %{with python2} | |
367df2cb JB |
89 | %py_build |
90 | # deprecated target, but sometimes still used: %{?with_tests:test} | |
91 | ||
92 | %if %{with tests} | |
93 | %{__python} -m pytest ... | |
94 | %endif | |
4e897198 JK |
95 | %endif |
96 | ||
97 | %if %{with python3} | |
367df2cb JB |
98 | %py3_build |
99 | # deprecated target, but sometimes still used: %{?with_tests:test} | |
100 | ||
101 | %if %{with tests} | |
102 | %{__python3} -m pytest ... | |
103 | %endif | |
4e897198 JK |
104 | %endif |
105 | ||
106 | %if %{with doc} | |
367df2cb JB |
107 | %{__make} -C docs html |
108 | # if particular python version required - append: | |
109 | # SPHINXBUILD=sphinx-build-3 | |
110 | rm -rf docs/_build/html/_sources | |
4e897198 JK |
111 | %endif |
112 | ||
113 | %install | |
114 | rm -rf $RPM_BUILD_ROOT | |
8329d0fc | 115 | |
4e897198 JK |
116 | %if %{with python2} |
117 | %py_install | |
8329d0fc | 118 | |
4e897198 JK |
119 | %py_postclean |
120 | %endif | |
121 | ||
122 | %if %{with python3} | |
123 | %py3_install | |
124 | %endif | |
125 | ||
367df2cb | 126 | %if %{with enable_if_there_are_examples_provided_in_package} |
4e897198 | 127 | %if %{with python2} |
733ed350 ER |
128 | install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} |
129 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} | |
130 | find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \ | |
131 | | xargs sed -i '1s|^#!.*python\b|#!%{__python}|' | |
4e897198 JK |
132 | %endif |
133 | %if %{with python3} | |
134 | install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
135 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
136 | find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \ | |
137 | | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' | |
138 | %endif | |
367df2cb | 139 | %endif |
4e897198 JK |
140 | |
141 | %clean | |
142 | rm -rf $RPM_BUILD_ROOT | |
143 | ||
144 | %if %{with python2} | |
145 | %files | |
146 | %defattr(644,root,root,755) | |
147 | %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO | |
148 | %dir %{py_sitedir}/%{module} | |
149 | %{py_sitedir}/%{module}/*.py[co] | |
150 | %attr(755,root,root) %{py_sitedir}/%{module}/*.so | |
4e897198 | 151 | %{py_sitedir}/%{module}-%{version}-py*.egg-info |
4e897198 JK |
152 | %{_examplesdir}/%{name}-%{version} |
153 | %endif | |
154 | ||
155 | %if %{with python3} | |
156 | %files -n python3-%{module} | |
157 | %defattr(644,root,root,755) | |
8329d0fc | 158 | # copy %doc from python2 package here |
4e897198 JK |
159 | %dir %{py3_sitedir}/%{module} |
160 | %{py3_sitedir}/%{module}/*.py | |
161 | %attr(755,root,root) %{py3_sitedir}/%{module}/*.so | |
162 | %{py3_sitedir}/%{module}/__pycache__ | |
163 | %{py3_sitedir}/%{module}-%{version}-py*.egg-info | |
164 | %{_examplesdir}/python3-%{module}-%{version} | |
165 | %endif | |
166 | ||
167 | %if %{with doc} | |
168 | %files apidocs | |
169 | %defattr(644,root,root,755) | |
170 | %doc docs/_build/html/* | |
171 | %endif |