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: python-devel
21 BuildRequires: python-distribute
22 BuildRequires: rpm-pythonprov
23 # if py_postclean is used
24 BuildRequires: rpmbuild(macros) >= 1.219
25 # when python3 present
26 BuildRequires: sed >= 4.0
28 BuildRequires: python3-devel
29 BuildRequires: python3-distribute
30 BuildRequires: python3-modules
32 #Requires: python-libs
33 Requires: python-modules
35 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
39 %description -l pl.UTF-8
41 %package -n python3-%{module}
44 Group: Libraries/Python
46 %description -n python3-%{module}
48 %description -n python3-%{module} -l pl.UTF-8
51 Summary: %{module} API documentation
52 Summary(pl.UTF-8): Dokumentacja API %{module}
56 API documentation for %{module}.
58 %description apidocs -l pl.UTF-8
59 Dokumentacja API %{module}.
62 %setup -q -n %{module}-%{version}
64 # fix #!/usr/bin/env python -> #!/usr/bin/python:
65 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
69 # CC/CFLAGS is only for arch packages - remove on noarch packages
71 CFLAGS="%{rpmcflags}" \
72 %{__python} setup.py build --build-base build-2 %{?with_tests:test}
76 # CC/CFLAGS is only for arch packages - remove on noarch packages
78 CFLAGS="%{rpmcflags}" \
79 %{__python3} setup.py build --build-base build-3 %{?with_tests:test}
85 rm -rf _build/html/_sources
89 rm -rf $RPM_BUILD_ROOT
92 %{__python} setup.py \
93 build --build-base build-2 \
94 install --skip-build \
95 --root=$RPM_BUILD_ROOT \
102 %{__python3} setup.py \
103 build --build-base build-3 \
104 install --skip-build \
105 --root=$RPM_BUILD_ROOT \
109 # in case there are examples provided
111 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
112 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
115 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
116 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
117 find $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} -name '*.py' \
118 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
121 # when files are installed in other way that standard 'setup.py
122 # they need to be (re-)compiled
123 ## change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
124 #%%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
125 #%%py_comp $RPM_BUILD_ROOT%{py_sitedir}
129 rm -rf $RPM_BUILD_ROOT
133 %defattr(644,root,root,755)
134 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
135 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
136 %{py_sitedir}/*.py[co]
137 %attr(755,root,root) %{py_sitedir}/*.so
138 %if "%{py_ver}" > "2.4"
139 %{py_sitedir}/TEMPLATE-*.egg-info
141 %{_examplesdir}/%{name}-%{version}
145 %files -n python3-%{module}
146 %defattr(644,root,root,755)
147 %doc AUTHORS CHANGES LICENSE
148 %{py3_sitescriptdir}/%{module}
149 %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
150 %{_examplesdir}/%{python3}-%{module}-%{version}
155 %defattr(644,root,root,755)
156 %doc docs/_build/html/*