3 %bcond_without doc # don't build doc
4 %bcond_without tests # do not perform "make test"
5 %bcond_without python2 # CPython 2.x module
6 %bcond_without python3 # CPython 3.x module
8 %define module template
11 # Name must match the python module/package name (as in 'import' statement)
12 Name: python-%{module}
15 License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
16 Group: Libraries/Python
17 Source0: %{name}-%{version}.tar.gz
20 # remove BR: python-devel for 'noarch' packages.
21 BuildRequires: rpm-pythonprov
22 # if py_postclean is used
23 BuildRequires: rpmbuild(macros) >= 1.219
24 # if py3* macros are used
25 BuildRequires: rpmbuild(macros) >= 1.612
26 # when using /usr/bin/env or other in-place substitutions
27 #BuildRequires: sed >= 4.0
28 # when python3 present
30 BuildRequires: python-devel
31 BuildRequires: python-setuptools
34 BuildRequires: python3-devel
35 BuildRequires: python3-modules
36 BuildRequires: python3-setuptools
38 # Below Rs only work for main package (python2)
39 #Requires: python-libs
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
75 # setup copy of source in py3 dir
82 # CC/CFLAGS is only for arch packages - remove on noarch packages
84 CFLAGS="%{rpmcppflags} %{rpmcflags}" \
85 %{__python} setup.py build --build-base build-2 %{?with_tests:test}
89 # CC/CFLAGS is only for arch packages - remove on noarch packages
91 CFLAGS="%{rpmcppflags} %{rpmcflags}" \
92 %{__python3} setup.py build --build-base build-3 %{?with_tests:test}
98 rm -rf _build/html/_sources
102 rm -rf $RPM_BUILD_ROOT
105 %{__python} setup.py \
106 build --build-base build-2 \
107 install --skip-build \
109 --root=$RPM_BUILD_ROOT
115 %{__python3} setup.py \
116 build --build-base build-3 \
117 install --skip-build \
119 --root=$RPM_BUILD_ROOT
122 # in case there are examples provided
124 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
125 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
128 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
129 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
130 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
131 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
134 # when files are installed in other way that standard 'setup.py
135 # they need to be (re-)compiled
136 ## change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
137 #%%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
138 #%%py_comp $RPM_BUILD_ROOT%{py_sitedir}
142 rm -rf $RPM_BUILD_ROOT
146 %defattr(644,root,root,755)
147 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
148 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
149 %{py_sitedir}/*.py[co]
150 %attr(755,root,root) %{py_sitedir}/*.so
151 %if "%{py_ver}" > "2.4"
152 %{py_sitedir}/%{module}-%{version}-py*.egg-info
154 %{_examplesdir}/%{name}-%{version}
158 %files -n python3-%{module}
159 %defattr(644,root,root,755)
160 %doc AUTHORS CHANGES LICENSE
161 %{py3_sitescriptdir}/%{module}
162 %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
163 %{_examplesdir}/python3-%{module}-%{version}
168 %defattr(644,root,root,755)
169 %doc docs/_build/html/*