]> git.pld-linux.org Git - projects/template-specs.git/blame_incremental - python-ext.spec
- use explicit PYTEST_PLUGINS lists for reliable tests (not failing if some conflicti...
[projects/template-specs.git] / python-ext.spec
... / ...
CommitLineData
1#
2# This is template for python2/python3 extension modules (including compiled C code)
3# use template-specs/python.spec for pure python packages
4# use template-specs/python3-ext.spec for python3 only packages
5#
6# Conditional build:
7%bcond_without doc # API documentation
8%bcond_without tests # unit tests
9%bcond_without python2 # CPython 2.x module
10%bcond_without python3 # CPython 3.x module
11
12%define module template
13Summary: -
14Summary(pl.UTF-8): -
15# Name must match the python module/package name (as on pypi or in 'import' statement)
16Name: python-%{module}
17Version: _
18Release: 0.1
19License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
20Group: Libraries/Python
21# if pypi:
22#Source0Download: https://pypi.org/simple/MODULE/
23Source0: https://files.pythonhosted.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz
24# Source0-md5: -
25#URL: https://pypi.org/project/MODULE/
26URL: -
27%if %{with python2}
28BuildRequires: python-devel >= 1:2.5
29#BuildRequires: python-setuptools
30%if %{with tests}
31#BuildRequires: python-
32%endif
33%endif
34%if %{with python3}
35BuildRequires: python3-devel >= 1:3.2
36#BuildRequires: python3-setuptools
37%if %{with tests}
38#BuildRequires: python3-
39%endif
40%endif
41# if using noarch subpackage:
42#BuildRequires: rpm-build >= 4.6
43BuildRequires: rpm-pythonprov
44# for the py_build, py_install macros
45BuildRequires: rpmbuild(macros) >= 1.714
46# when using /usr/bin/env or other in-place substitutions
47#BuildRequires: sed >= 4.0
48%if %{with doc}
49BuildRequires: sphinx-pdg # -2 or -3
50%endif
51# replace with other requires if defined in setup.py
52Requires: python-modules >= 1:2.5
53BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
54
55%description
56
57%description -l pl.UTF-8
58
59%package -n python3-%{module}
60Summary: -
61Summary(pl.UTF-8): -
62Group: Libraries/Python
63Requires: python3-modules >= 1:3.2
64
65%description -n python3-%{module}
66
67%description -n python3-%{module} -l pl.UTF-8
68
69%package apidocs
70Summary: API documentation for Python %{module} module
71Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module}
72Group: Documentation
73BuildArch: noarch
74
75%description apidocs
76API documentation for Python %{module} module.
77
78%description apidocs -l pl.UTF-8
79Dokumentacja API modułu Pythona %{module}.
80
81%prep
82%setup -q -n %{module}-%{version}
83
84# fix #!/usr/bin/env python -> #!/usr/bin/python:
85#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
86
87%build
88%if %{with python2}
89%py_build
90# deprecated target, but sometimes still used: %{?with_tests:test}
91
92%if %{with tests}
93# use explicit plugins list for reliable builds (delete PYTEST_PLUGINS if empty)
94PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
95PYTEST_PLUGINS= \
96%{__python} -m pytest ...
97%endif
98%endif
99
100%if %{with python3}
101%py3_build
102# deprecated target, but sometimes still used: %{?with_tests:test}
103
104%if %{with tests}
105# use explicit plugins list for reliable builds (delete PYTEST_PLUGINS if empty)
106PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
107PYTEST_PLUGINS= \
108%{__python3} -m pytest ...
109%endif
110%endif
111
112%if %{with doc}
113%{__make} -C docs html
114# if particular python version required - append:
115# SPHINXBUILD=sphinx-build-3
116rm -rf docs/_build/html/_sources
117%endif
118
119%install
120rm -rf $RPM_BUILD_ROOT
121
122%if %{with python2}
123%py_install
124
125%py_postclean
126%endif
127
128%if %{with python3}
129%py3_install
130%endif
131
132%if %{with enable_if_there_are_examples_provided_in_package}
133%if %{with python2}
134install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
135cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
136find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
137 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
138%endif
139%if %{with python3}
140install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
141cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
142find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
143 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
144%endif
145%endif
146
147%clean
148rm -rf $RPM_BUILD_ROOT
149
150%if %{with python2}
151%files
152%defattr(644,root,root,755)
153%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
154%dir %{py_sitedir}/%{module}
155%{py_sitedir}/%{module}/*.py[co]
156%attr(755,root,root) %{py_sitedir}/%{module}/*.so
157%{py_sitedir}/%{module}-%{version}-py*.egg-info
158%{_examplesdir}/%{name}-%{version}
159%endif
160
161%if %{with python3}
162%files -n python3-%{module}
163%defattr(644,root,root,755)
164# copy %doc from python2 package here
165%dir %{py3_sitedir}/%{module}
166%{py3_sitedir}/%{module}/*.py
167%attr(755,root,root) %{py3_sitedir}/%{module}/*.so
168%{py3_sitedir}/%{module}/__pycache__
169%{py3_sitedir}/%{module}-%{version}-py*.egg-info
170%{_examplesdir}/python3-%{module}-%{version}
171%endif
172
173%if %{with doc}
174%files apidocs
175%defattr(644,root,root,755)
176%doc docs/_build/html/*
177%endif
This page took 0.074866 seconds and 4 git commands to generate.