]> git.pld-linux.org Git - projects/template-specs.git/blame - python-ext.spec
py_build/py_install: BR: rpmbuild(macros) >= 1.714
[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): -
14# Name must match the python module/package name (as in 'import' statement)
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
89
90%if %{with python2}
91%py_install
92
93%py_postclean
94%endif
95
96%if %{with python3}
97%py3_install
98%endif
99
100# in case there are examples provided
101%if %{with python2}
102install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
103cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
104%endif
105%if %{with python3}
106install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
107cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
108find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
109 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
110%endif
111
112%clean
113rm -rf $RPM_BUILD_ROOT
114
115%if %{with python2}
116%files
117%defattr(644,root,root,755)
118%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
119%dir %{py_sitedir}/%{module}
120%{py_sitedir}/%{module}/*.py[co]
121%attr(755,root,root) %{py_sitedir}/%{module}/*.so
122%if "%{py_ver}" > "2.4"
123%{py_sitedir}/%{module}-%{version}-py*.egg-info
124%endif
125%{_examplesdir}/%{name}-%{version}
126%endif
127
128%if %{with python3}
129%files -n python3-%{module}
130%defattr(644,root,root,755)
131%doc AUTHORS CHANGES LICENSE
132%dir %{py3_sitedir}/%{module}
133%{py3_sitedir}/%{module}/*.py
134%attr(755,root,root) %{py3_sitedir}/%{module}/*.so
135%{py3_sitedir}/%{module}/__pycache__
136%{py3_sitedir}/%{module}-%{version}-py*.egg-info
137%{_examplesdir}/python3-%{module}-%{version}
138%endif
139
140%if %{with doc}
141%files apidocs
142%defattr(644,root,root,755)
143%doc docs/_build/html/*
144%endif
This page took 0.059507 seconds and 4 git commands to generate.