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 # when using /usr/bin/env or other in-place substitutions
25 #BuildRequires: sed >= 4.0
26 # when python3 present
28 BuildRequires: python-devel
29 BuildRequires: python-setuptools
32 BuildRequires: python3-devel
33 BuildRequires: python3-modules
34 BuildRequires: python3-setuptools
36 # Below Rs only work for main package (python2)
37 #Requires: python-libs
38 Requires: python-modules
40 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
44 %description -l pl.UTF-8
46 %package -n python3-%{module}
49 Group: Libraries/Python
50 Requires: python3-modules
52 %description -n python3-%{module}
54 %description -n python3-%{module} -l pl.UTF-8
57 Summary: %{module} API documentation
58 Summary(pl.UTF-8): Dokumentacja API %{module}
62 API documentation for %{module}.
64 %description apidocs -l pl.UTF-8
65 Dokumentacja API %{module}.
68 %setup -q -n %{module}-%{version}
70 # fix #!/usr/bin/env python -> #!/usr/bin/python:
71 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
73 # setup copy of source in py3 dir
80 # CC/CFLAGS is only for arch packages - remove on noarch packages
82 CFLAGS="%{rpmcppflags} %{rpmcflags}" \
83 %{__python} setup.py build --build-base build-2 %{?with_tests:test}
87 # CC/CFLAGS is only for arch packages - remove on noarch packages
89 CFLAGS="%{rpmcppflags} %{rpmcflags}" \
90 %{__python3} setup.py build --build-base build-3 %{?with_tests:test}
96 rm -rf _build/html/_sources
100 rm -rf $RPM_BUILD_ROOT
103 %{__python} setup.py \
104 build --build-base build-2 \
105 install --skip-build \
107 --root=$RPM_BUILD_ROOT
113 %{__python3} setup.py \
114 build --build-base build-3 \
115 install --skip-build \
117 --root=$RPM_BUILD_ROOT
120 # in case there are examples provided
122 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
123 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
126 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
127 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
128 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
129 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
132 # when files are installed in other way that standard 'setup.py
133 # they need to be (re-)compiled
134 ## change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
135 #%%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
136 #%%py_comp $RPM_BUILD_ROOT%{py_sitedir}
140 rm -rf $RPM_BUILD_ROOT
144 %defattr(644,root,root,755)
145 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
146 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
147 %{py_sitedir}/*.py[co]
148 %attr(755,root,root) %{py_sitedir}/*.so
149 %if "%{py_ver}" > "2.4"
150 %{py_sitedir}/%{module}-%{version}-py*.egg-info
152 %{_examplesdir}/%{name}-%{version}
156 %files -n python3-%{module}
157 %defattr(644,root,root,755)
158 %doc AUTHORS CHANGES LICENSE
159 %{py3_sitescriptdir}/%{module}
160 %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
161 %{_examplesdir}/python3-%{module}-%{version}
166 %defattr(644,root,root,755)
167 %doc docs/_build/html/*