2 # This is template for python2/python3 extension modules (including compiled C code)
3 # use template-specs/python.spec for pure python packages
4 # use template-specs/python3-ext.spec for python3 only packages
7 %bcond_without doc # API documentation
8 %bcond_without tests # unit tests
9 %bcond_without python2 # CPython 2.x module
10 %bcond_without python3 # CPython 3.x module
12 %define module template
15 # Name must match the python module/package name (as on pypi or in 'import' statement)
16 Name: python-%{module}
19 License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
20 Group: Libraries/Python
22 #Source0Download: https://pypi.org/simple/MODULE/
23 Source0: https://files.pythonhosted.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz
25 #URL: https://pypi.org/project/MODULE/
28 BuildRequires: python-devel >= 1:2.5
29 #BuildRequires: python-setuptools
31 #BuildRequires: python-
35 BuildRequires: python3-devel >= 1:3.2
36 #BuildRequires: python3-setuptools
38 #BuildRequires: python3-
41 BuildRequires: rpm-pythonprov
42 # for the py_build, py_install macros
43 BuildRequires: rpmbuild(macros) >= 1.714
44 # if using noarchpackage, replace with:
45 #BuildRequires: rpmbuild(macros) >= 1.752
46 # when using /usr/bin/env or other in-place substitutions
47 #BuildRequires: sed >= 4.0
49 BuildRequires: sphinx-pdg # -2 or -3
51 # replace with other requires if defined in setup.py
52 Requires: python-modules >= 1:2.5
53 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
57 %description -l pl.UTF-8
59 %package -n python3-%{module}
62 Group: Libraries/Python
63 Requires: python3-modules >= 1:3.2
65 %description -n python3-%{module}
67 %description -n python3-%{module} -l pl.UTF-8
70 Summary: %{module} API documentation
71 Summary(pl.UTF-8): Dokumentacja API %{module}
76 API documentation for %{module}.
78 %description apidocs -l pl.UTF-8
79 Dokumentacja API %{module}.
82 %setup -q -n %{module}-%{version}
84 # fix #!/usr/bin/env python -> #!/usr/bin/python:
85 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
90 # deprecated target, but sometimes still used: %{?with_tests:test}
93 %{__python} -m pytest ...
99 # deprecated target, but sometimes still used: %{?with_tests:test}
102 %{__python3} -m pytest ...
107 %{__make} -C docs html
108 # if particular python version required - append:
109 # SPHINXBUILD=sphinx-build-3
110 rm -rf docs/_build/html/_sources
114 rm -rf $RPM_BUILD_ROOT
126 %if %{with enable_if_there_are_examples_provided_in_package}
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}|'
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}|'
142 rm -rf $RPM_BUILD_ROOT
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
151 %{py_sitedir}/%{module}-%{version}-py*.egg-info
152 %{_examplesdir}/%{name}-%{version}
156 %files -n python3-%{module}
157 %defattr(644,root,root,755)
158 # copy %doc from python2 package here
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}
169 %defattr(644,root,root,755)
170 %doc docs/_build/html/*