]>
Commit | Line | Data |
---|---|---|
1 | # | |
2 | # This is template for pure python modules (noarch) | |
3 | # use template-specs/python-ext.spec for binary python packages | |
4 | # | |
5 | # | |
6 | # Conditional build: | |
7 | %bcond_without doc # don't build doc | |
8 | %bcond_without tests # do not perform "make test" | |
9 | %bcond_without python2 # CPython 2.x module | |
10 | %bcond_without python3 # CPython 3.x module | |
11 | ||
12 | # NOTE: 'module' should match the python import path, not the egg name | |
13 | %define module template | |
14 | Summary: - | |
15 | Summary(pl.UTF-8): - | |
16 | # Name must match the python module/package name (as on pypi or in 'import' statement) | |
17 | Name: python-%{module} | |
18 | Version: _ | |
19 | Release: 0.1 | |
20 | License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here) | |
21 | Group: Libraries/Python | |
22 | Source0: https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz | |
23 | # Source0-md5: - | |
24 | #URL: https://pypi.python.org/pypi/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-modules | |
31 | #BuildRequires: python-setuptools | |
32 | %endif | |
33 | %if %{with python3} | |
34 | BuildRequires: python3-modules | |
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 | BuildArch: noarch | |
42 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
43 | ||
44 | %description | |
45 | ||
46 | %description -l pl.UTF-8 | |
47 | ||
48 | %package -n python3-%{module} | |
49 | Summary: - | |
50 | Summary(pl.UTF-8): - | |
51 | Group: Libraries/Python | |
52 | Requires: python3-modules | |
53 | ||
54 | %description -n python3-%{module} | |
55 | ||
56 | %description -n python3-%{module} -l pl.UTF-8 | |
57 | ||
58 | %package apidocs | |
59 | Summary: %{module} API documentation | |
60 | Summary(pl.UTF-8): Dokumentacja API %{module} | |
61 | Group: Documentation | |
62 | ||
63 | %description apidocs | |
64 | API documentation for %{module}. | |
65 | ||
66 | %description apidocs -l pl.UTF-8 | |
67 | Dokumentacja API %{module}. | |
68 | ||
69 | %prep | |
70 | %setup -q -n %{module}-%{version} | |
71 | ||
72 | # fix #!/usr/bin/env python -> #!/usr/bin/python: | |
73 | #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py | |
74 | ||
75 | %build | |
76 | %if %{with python2} | |
77 | %py_build %{?with_tests:test} | |
78 | %endif | |
79 | ||
80 | %if %{with python3} | |
81 | %py3_build %{?with_tests:test} | |
82 | %endif | |
83 | ||
84 | %if %{with doc} | |
85 | cd docs | |
86 | %{__make} -j1 html | |
87 | rm -rf _build/html/_sources | |
88 | %endif | |
89 | ||
90 | %install | |
91 | rm -rf $RPM_BUILD_ROOT | |
92 | ||
93 | %if %{with python2} | |
94 | %py_install | |
95 | ||
96 | # when files are installed in other way that standard 'setup.py | |
97 | # they need to be (re-)compiled | |
98 | # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages! | |
99 | %py_ocomp $RPM_BUILD_ROOT%{py_sitedir} | |
100 | %py_comp $RPM_BUILD_ROOT%{py_sitedir} | |
101 | ||
102 | %py_postclean | |
103 | %endif | |
104 | ||
105 | %if %{with python3} | |
106 | %py3_install | |
107 | %endif | |
108 | ||
109 | # in case there are examples provided | |
110 | %if %{with python2} | |
111 | install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} | |
112 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} | |
113 | %endif | |
114 | %if %{with python3} | |
115 | install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
116 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
117 | find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \ | |
118 | | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' | |
119 | %endif | |
120 | ||
121 | %clean | |
122 | rm -rf $RPM_BUILD_ROOT | |
123 | ||
124 | %if %{with python2} | |
125 | %files | |
126 | %defattr(644,root,root,755) | |
127 | %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO | |
128 | %{py_sitescriptdir}/%{module} | |
129 | %if "%{py_ver}" > "2.4" | |
130 | %{py_sitescriptdir}/%{module}-%{version}-py*.egg-info | |
131 | %endif | |
132 | %{_examplesdir}/%{name}-%{version} | |
133 | %endif | |
134 | ||
135 | %if %{with python3} | |
136 | %files -n python3-%{module} | |
137 | %defattr(644,root,root,755) | |
138 | %doc AUTHORS CHANGES LICENSE | |
139 | %{py3_sitescriptdir}/%{module} | |
140 | %{py3_sitescriptdir}/%{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 |