3 %bcond_without tests # do not perform "make test"
4 %bcond_without python2 # CPython 2.x module
5 %bcond_without python3 # CPython 3.x module
7 %define module template
10 # Name must match the python module/package name (as in 'import' statement)
11 Name: python-%{module}
14 License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
15 Group: Libraries/Python
16 Source0: %{name}-%{version}.tar.gz
19 # remove BR: python-devel for 'noarch' packages.
20 BuildRequires: rpm-pythonprov
21 # if py_postclean is used
22 BuildRequires: rpmbuild(macros) >= 1.219
23 # when using /usr/bin/env or other in-place substitutions
24 #BuildRequires: sed >= 4.0
26 BuildRequires: python-devel
27 BuildRequires: python-distribute
30 BuildRequires: python3-devel
31 BuildRequires: python3-distribute
32 BuildRequires: python3-modules
34 #Requires: python-libs
35 Requires: python-modules
37 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
41 %description -l pl.UTF-8
43 %package -n python3-%{module}
46 Group: Libraries/Python
48 %description -n python3-%{module}
50 %description -n python3-%{module} -l pl.UTF-8
53 Summary: %{module} API documentation
54 Summary(pl.UTF-8): Dokumentacja API %{module}
58 API documentation for %{module}.
60 %description apidocs -l pl.UTF-8
61 Dokumentacja API %{module}.
64 %setup -q -n %{module}-%{version}
66 # fix #!/usr/bin/env python -> #!/usr/bin/python:
67 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
71 # CC/CFLAGS is only for arch packages - remove on noarch packages
73 CFLAGS="%{rpmcflags}" \
74 %{__python} setup.py build --build-base build-2 %{?with_tests:test}
78 # CC/CFLAGS is only for arch packages - remove on noarch packages
80 CFLAGS="%{rpmcflags}" \
81 %{__python3} setup.py build --build-base build-3 %{?with_tests:test}
87 rm -rf _build/html/_sources
91 rm -rf $RPM_BUILD_ROOT
94 %{__python} setup.py \
95 build --build-base build-2 \
96 install --skip-build \
98 --root=$RPM_BUILD_ROOT
104 %{__python3} setup.py \
105 build --build-base build-3 \
106 install --skip-build \
108 --root=$RPM_BUILD_ROOT
111 # in case there are examples provided
113 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
114 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
117 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
118 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
119 find $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} -name '*.py' \
120 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
123 # when files are installed in other way that standard 'setup.py
124 # they need to be (re-)compiled
125 ## change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
126 #%%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
127 #%%py_comp $RPM_BUILD_ROOT%{py_sitedir}
131 rm -rf $RPM_BUILD_ROOT
135 %defattr(644,root,root,755)
136 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
137 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
138 %{py_sitedir}/*.py[co]
139 %attr(755,root,root) %{py_sitedir}/*.so
140 %if "%{py_ver}" > "2.4"
141 %{py_sitedir}/TEMPLATE-*.egg-info
143 %{_examplesdir}/%{name}-%{version}
147 %files -n python3-%{module}
148 %defattr(644,root,root,755)
149 %doc AUTHORS CHANGES LICENSE
150 %{py3_sitescriptdir}/%{module}
151 %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
152 %{_examplesdir}/%{python3}-%{module}-%{version}
157 %defattr(644,root,root,755)
158 %doc docs/_build/html/*