]> git.pld-linux.org Git - projects/template-specs.git/blame - python-ext.spec
pecl: add example how to make failed tests as XFAIL
[projects/template-specs.git] / python-ext.spec
CommitLineData
4e897198
JK
1#
2# This is template for python extension modules (including compiled C code)
3# use template-specs/python.spec for pure python packages
4#
5# Conditional build:
6%bcond_without doc # don't build doc
7%bcond_without tests # do not perform "make test"
8%bcond_without python2 # CPython 2.x module
9%bcond_without python3 # CPython 3.x module
10
11%define module template
12Summary: -
13Summary(pl.UTF-8): -
d1ab9a90 14# Name must match the python module/package name (as on pypi or in 'import' statement)
4e897198
JK
15Name: python-%{module}
16Version: _
17Release: 0.1
18License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
19Group: Libraries/Python
20Source0: https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz
21# Source0-md5: -
22#URL: https://pypi.python.org/pypi/MODULE
23URL: -
24BuildRequires: rpm-pythonprov
25# for the py_build, py_install macros
038fedf4 26BuildRequires: rpmbuild(macros) >= 1.714
4e897198
JK
27%if %{with python2}
28BuildRequires: python-devel
29#BuildRequires: python-setuptools
30%endif
31%if %{with python3}
32BuildRequires: python3-devel
33#BuildRequires: python3-setuptools
34%endif
35# when using /usr/bin/env or other in-place substitutions
36#BuildRequires: sed >= 4.0
37# replace with other requires if defined in setup.py
38Requires: python-modules
39BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
40
41%description
42
43%description -l pl.UTF-8
44
45%package -n python3-%{module}
46Summary: -
47Summary(pl.UTF-8): -
48Group: Libraries/Python
49Requires: python3-modules
50
51%description -n python3-%{module}
52
53%description -n python3-%{module} -l pl.UTF-8
54
55%package apidocs
56Summary: %{module} API documentation
57Summary(pl.UTF-8): Dokumentacja API %{module}
58Group: Documentation
59
60%description apidocs
61API documentation for %{module}.
62
63%description apidocs -l pl.UTF-8
64Dokumentacja API %{module}.
65
66%prep
67%setup -q -n %{module}-%{version}
68
69# fix #!/usr/bin/env python -> #!/usr/bin/python:
70#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
71
72%build
73%if %{with python2}
74%py_build %{?with_tests:test}
75%endif
76
77%if %{with python3}
78%py3_build %{?with_tests:test}
79%endif
80
81%if %{with doc}
82cd docs
83%{__make} -j1 html
84rm -rf _build/html/_sources
85%endif
86
87%install
88rm -rf $RPM_BUILD_ROOT
4e897198
JK
89%if %{with python2}
90%py_install
4e897198
JK
91%py_postclean
92%endif
93
94%if %{with python3}
95%py3_install
96%endif
97
4e897198 98%if %{with python2}
733ed350
ER
99install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
100cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
101find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
102 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
4e897198
JK
103%endif
104%if %{with python3}
105install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
106cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
107find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
108 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
109%endif
110
111%clean
112rm -rf $RPM_BUILD_ROOT
113
114%if %{with python2}
115%files
116%defattr(644,root,root,755)
117%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
118%dir %{py_sitedir}/%{module}
119%{py_sitedir}/%{module}/*.py[co]
120%attr(755,root,root) %{py_sitedir}/%{module}/*.so
4e897198 121%{py_sitedir}/%{module}-%{version}-py*.egg-info
4e897198
JK
122%{_examplesdir}/%{name}-%{version}
123%endif
124
125%if %{with python3}
126%files -n python3-%{module}
127%defattr(644,root,root,755)
128%doc AUTHORS CHANGES LICENSE
129%dir %{py3_sitedir}/%{module}
130%{py3_sitedir}/%{module}/*.py
131%attr(755,root,root) %{py3_sitedir}/%{module}/*.so
132%{py3_sitedir}/%{module}/__pycache__
133%{py3_sitedir}/%{module}-%{version}-py*.egg-info
134%{_examplesdir}/python3-%{module}-%{version}
135%endif
136
137%if %{with doc}
138%files apidocs
139%defattr(644,root,root,755)
140%doc docs/_build/html/*
141%endif
This page took 0.819865 seconds and 4 git commands to generate.