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 %define module template
15 # Name must match the python module/package name (as 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
21 Source0: https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz
23 #URL: https://pypi.python.org/pypi/MODULE
25 BuildRequires: rpm-pythonprov
26 # for the py_build, py_install macros
27 BuildRequires: rpmbuild(macros) >= 1.713
29 BuildRequires: python-modules
30 #BuildRequires: python-setuptools
33 BuildRequires: python3-modules
34 #BuildRequires: python3-setuptools
36 # when using /usr/bin/env or other in-place substitutions
37 #BuildRequires: sed >= 4.0
38 # replace with other requires if defined in setup.py
39 Requires: python-modules
41 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
45 %description -l pl.UTF-8
47 %package -n python3-%{module}
50 Group: Libraries/Python
51 Requires: python3-modules
53 %description -n python3-%{module}
55 %description -n python3-%{module} -l pl.UTF-8
58 Summary: %{module} API documentation
59 Summary(pl.UTF-8): Dokumentacja API %{module}
63 API documentation for %{module}.
65 %description apidocs -l pl.UTF-8
66 Dokumentacja API %{module}.
69 %setup -q -n %{module}-%{version}
71 # fix #!/usr/bin/env python -> #!/usr/bin/python:
72 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
76 %py_build %{?with_tests:test}
80 %py3_build %{?with_tests:test}
86 rm -rf _build/html/_sources
90 rm -rf $RPM_BUILD_ROOT
102 # in case there are examples provided
104 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
105 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
108 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
109 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
110 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
111 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
115 rm -rf $RPM_BUILD_ROOT
119 %defattr(644,root,root,755)
120 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
121 %{py_sitescriptdir}/%{module}
122 %if "%{py_ver}" > "2.4"
123 %{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
125 %{_examplesdir}/%{name}-%{version}
129 %files -n python3-%{module}
130 %defattr(644,root,root,755)
131 %doc AUTHORS CHANGES LICENSE
132 %{py3_sitescriptdir}/%{module}
133 %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
134 %{_examplesdir}/python3-%{module}-%{version}
139 %defattr(644,root,root,755)
140 %doc docs/_build/html/*