]> git.pld-linux.org Git - projects/template-specs.git/blob - python-ext.spec
Python template cleanup and update
[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 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 Source0:        https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz
21 # Source0-md5:  -
22 #URL:           https://pypi.python.org/pypi/MODULE
23 URL:            -
24 BuildRequires:  rpm-pythonprov
25 # for the py_build, py_install macros
26 BuildRequires:  rpmbuild(macros) >= 1.710
27 %if %{with python2}
28 BuildRequires:  python-devel
29 #BuildRequires: python-setuptools
30 %endif
31 %if %{with python3}
32 BuildRequires:  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
38 Requires:       python-modules
39 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
40
41 %description
42
43 %description -l pl.UTF-8
44
45 %package -n python3-%{module}
46 Summary:        -
47 Summary(pl.UTF-8):      -
48 Group:          Libraries/Python
49 Requires:       python3-modules
50
51 %description -n python3-%{module}
52
53 %description -n python3-%{module} -l pl.UTF-8
54
55 %package apidocs
56 Summary:        %{module} API documentation
57 Summary(pl.UTF-8):      Dokumentacja API %{module}
58 Group:          Documentation
59
60 %description apidocs
61 API documentation for %{module}.
62
63 %description apidocs -l pl.UTF-8
64 Dokumentacja 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}
82 cd docs
83 %{__make} -j1 html
84 rm -rf _build/html/_sources
85 %endif
86
87 %install
88 rm -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}
102 install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
103 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
104 %endif
105 %if %{with python3}
106 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
107 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
108 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
109         | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
110 %endif
111
112 %clean
113 rm -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.577862 seconds and 4 git commands to generate.