2 # This is template for pure python modules (noarch)
3 # use template-specs/python-ext.spec for binary python packages
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
12 # NOTE: 'module' should match the python import path, not the egg name
13 %define module template
16 # Name must match the python module/package name (as on pypi or in 'import' statement)
17 Name: python-%{module}
20 License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
21 Group: Libraries/Python
22 Source0: https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz
24 #URL: https://pypi.python.org/pypi/MODULE
26 BuildRequires: rpm-pythonprov
27 # for the py_build, py_install macros
28 BuildRequires: rpmbuild(macros) >= 1.714
30 BuildRequires: python-modules
31 #BuildRequires: python-setuptools
34 BuildRequires: python3-modules
35 #BuildRequires: python3-setuptools
37 # when using /usr/bin/env or other in-place substitutions
38 #BuildRequires: sed >= 4.0
39 # replace with other requires if defined in setup.py
40 Requires: python-modules
42 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
46 %description -l pl.UTF-8
48 %package -n python3-%{module}
51 Group: Libraries/Python
52 Requires: python3-modules
54 %description -n python3-%{module}
56 %description -n python3-%{module} -l pl.UTF-8
59 Summary: %{module} API documentation
60 Summary(pl.UTF-8): Dokumentacja API %{module}
64 API documentation for %{module}.
66 %description apidocs -l pl.UTF-8
67 Dokumentacja API %{module}.
70 %setup -q -n %{module}-%{version}
72 # fix #!/usr/bin/env python -> #!/usr/bin/python:
73 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
77 %py_build %{?with_tests:test}
81 %py3_build %{?with_tests:test}
87 rm -rf _build/html/_sources
91 rm -rf $RPM_BUILD_ROOT
96 # when files are installed in other way that standard 'setup.py
97 # they need to be (re-)compiled
98 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
99 %py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
100 %py_comp $RPM_BUILD_ROOT%{py_sitedir}
109 # in case there are examples provided
111 install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
112 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
113 find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
114 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
117 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
118 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
119 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
120 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
124 rm -rf $RPM_BUILD_ROOT
128 %defattr(644,root,root,755)
129 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
130 %{py_sitescriptdir}/%{module}
131 %{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
132 %{_examplesdir}/python-%{module}-%{version}
136 %files -n python3-%{module}
137 %defattr(644,root,root,755)
138 %doc AUTHORS CHANGES LICENSE
139 %{py3_sitescriptdir}/%{module}
140 %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
141 %{_examplesdir}/python3-%{module}-%{version}
146 %defattr(644,root,root,755)
147 %doc docs/_build/html/*