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