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 using /usr/bin/env or other in-place substitutions
26 #BuildRequires: sed >= 4.0
27 # when python3 present
29 BuildRequires: python3-devel
30 BuildRequires: python3-distribute
31 BuildRequires: python3-modules
33 #Requires: python-libs
34 Requires: python-modules
36 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
40 %description -l pl.UTF-8
42 %package -n python3-%{module}
45 Group: Libraries/Python
47 %description -n python3-%{module}
49 %description -n python3-%{module} -l pl.UTF-8
52 Summary: %{module} API documentation
53 Summary(pl.UTF-8): Dokumentacja API %{module}
57 API documentation for %{module}.
59 %description apidocs -l pl.UTF-8
60 Dokumentacja API %{module}.
63 %setup -q -n %{module}-%{version}
65 # fix #!/usr/bin/env python -> #!/usr/bin/python:
66 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
70 # CC/CFLAGS is only for arch packages - remove on noarch packages
72 CFLAGS="%{rpmcflags}" \
73 %{__python} setup.py build --build-base build-2 %{?with_tests:test}
77 # CC/CFLAGS is only for arch packages - remove on noarch packages
79 CFLAGS="%{rpmcflags}" \
80 %{__python3} setup.py build --build-base build-3 %{?with_tests:test}
86 rm -rf _build/html/_sources
90 rm -rf $RPM_BUILD_ROOT
93 %{__python} setup.py \
94 build --build-base build-2 \
95 install --skip-build \
96 --root=$RPM_BUILD_ROOT \
103 %{__python3} setup.py \
104 build --build-base build-3 \
105 install --skip-build \
106 --root=$RPM_BUILD_ROOT \
110 # in case there are examples provided
112 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
113 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
116 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
117 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
118 find $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} -name '*.py' \
119 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
122 # when files are installed in other way that standard 'setup.py
123 # they need to be (re-)compiled
124 ## change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
125 #%%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
126 #%%py_comp $RPM_BUILD_ROOT%{py_sitedir}
130 rm -rf $RPM_BUILD_ROOT
134 %defattr(644,root,root,755)
135 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
136 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
137 %{py_sitedir}/*.py[co]
138 %attr(755,root,root) %{py_sitedir}/*.so
139 %if "%{py_ver}" > "2.4"
140 %{py_sitedir}/TEMPLATE-*.egg-info
142 %{_examplesdir}/%{name}-%{version}
146 %files -n python3-%{module}
147 %defattr(644,root,root,755)
148 %doc AUTHORS CHANGES LICENSE
149 %{py3_sitescriptdir}/%{module}
150 %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
151 %{_examplesdir}/%{python3}-%{module}-%{version}
156 %defattr(644,root,root,755)
157 %doc docs/_build/html/*