]>
Commit | Line | Data |
---|---|---|
4cdaa512 | 1 | # |
4e897198 JK |
2 | # This is template for pure python modules (noarch) |
3 | # use template-specs/python-ext.spec for binary python packages | |
4 | # | |
5 | # | |
4cdaa512 | 6 | # Conditional build: |
4e897198 | 7 | %bcond_without doc # don't build doc |
4cdaa512 | 8 | %bcond_without tests # do not perform "make test" |
0dd464e7 | 9 | %bcond_without python2 # CPython 2.x module |
d328d943 | 10 | %bcond_without python3 # CPython 3.x module |
4cdaa512 | 11 | |
b1e75c3c | 12 | # NOTE: 'module' should match the python import path, not the egg name |
b81eefa5 | 13 | %define module template |
7170a7b1 ER |
14 | Summary: - |
15 | Summary(pl.UTF-8): - | |
d1ab9a90 | 16 | # Name must match the python module/package name (as on pypi or in 'import' statement) |
b81eefa5 | 17 | Name: python-%{module} |
7170a7b1 ER |
18 | Version: _ |
19 | Release: 0.1 | |
20 | License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here) | |
6177d217 | 21 | Group: Libraries/Python |
4e897198 | 22 | Source0: https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz |
7170a7b1 | 23 | # Source0-md5: - |
4e897198 | 24 | #URL: https://pypi.python.org/pypi/MODULE |
7170a7b1 | 25 | URL: - |
0a48bf0d | 26 | BuildRequires: rpm-pythonprov |
4e897198 | 27 | # for the py_build, py_install macros |
038fedf4 | 28 | BuildRequires: rpmbuild(macros) >= 1.714 |
e3bbdd55 | 29 | %if %{with python2} |
4e897198 JK |
30 | BuildRequires: python-modules |
31 | #BuildRequires: python-setuptools | |
e3bbdd55 | 32 | %endif |
d328d943 | 33 | %if %{with python3} |
d328d943 | 34 | BuildRequires: python3-modules |
4e897198 | 35 | #BuildRequires: python3-setuptools |
d328d943 | 36 | %endif |
4e897198 JK |
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 | |
76f14f6a | 40 | Requires: python-modules |
4e897198 | 41 | BuildArch: noarch |
7170a7b1 ER |
42 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
43 | ||
44 | %description | |
45 | ||
e6f4b058 | 46 | %description -l pl.UTF-8 |
47 | ||
0dd464e7 JK |
48 | %package -n python3-%{module} |
49 | Summary: - | |
50 | Summary(pl.UTF-8): - | |
51 | Group: Libraries/Python | |
76f14f6a | 52 | Requires: python3-modules |
0dd464e7 JK |
53 | |
54 | %description -n python3-%{module} | |
55 | ||
56 | %description -n python3-%{module} -l pl.UTF-8 | |
57 | ||
660096c2 | 58 | %package apidocs |
d328d943 ER |
59 | Summary: %{module} API documentation |
60 | Summary(pl.UTF-8): Dokumentacja API %{module} | |
61 | Group: Documentation | |
62 | ||
660096c2 | 63 | %description apidocs |
d328d943 ER |
64 | API documentation for %{module}. |
65 | ||
660096c2 | 66 | %description apidocs -l pl.UTF-8 |
d328d943 ER |
67 | Dokumentacja API %{module}. |
68 | ||
7170a7b1 | 69 | %prep |
641675c1 | 70 | %setup -q -n %{module}-%{version} |
7170a7b1 | 71 | |
5a020810 | 72 | # fix #!/usr/bin/env python -> #!/usr/bin/python: |
cb13b64b | 73 | #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py |
5a020810 | 74 | |
7170a7b1 | 75 | %build |
d328d943 | 76 | %if %{with python2} |
4e897198 | 77 | %py_build %{?with_tests:test} |
0dd464e7 | 78 | %endif |
a4ec70eb | 79 | |
d328d943 | 80 | %if %{with python3} |
4e897198 | 81 | %py3_build %{?with_tests:test} |
d328d943 ER |
82 | %endif |
83 | ||
84 | %if %{with doc} | |
85 | cd docs | |
86 | %{__make} -j1 html | |
87 | rm -rf _build/html/_sources | |
88 | %endif | |
89 | ||
7170a7b1 ER |
90 | %install |
91 | rm -rf $RPM_BUILD_ROOT | |
d328d943 ER |
92 | |
93 | %if %{with python2} | |
4e897198 | 94 | %py_install |
d328d943 | 95 | |
caefe7e7 ER |
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} | |
99f75e1c JB |
101 | |
102 | %py_postclean | |
d328d943 ER |
103 | %endif |
104 | ||
d328d943 | 105 | %if %{with python3} |
4e897198 | 106 | %py3_install |
d328d943 ER |
107 | %endif |
108 | ||
0dd464e7 JK |
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} | |
f33c573b JK |
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' \ | |
073f936a | 118 | | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' |
0dd464e7 | 119 | %endif |
8424aa58 | 120 | |
7170a7b1 ER |
121 | %clean |
122 | rm -rf $RPM_BUILD_ROOT | |
123 | ||
0dd464e7 | 124 | %if %{with python2} |
7170a7b1 ER |
125 | %files |
126 | %defattr(644,root,root,755) | |
127 | %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO | |
4e897198 | 128 | %{py_sitescriptdir}/%{module} |
ef0b62a1 | 129 | %if "%{py_ver}" > "2.4" |
4e897198 | 130 | %{py_sitescriptdir}/%{module}-%{version}-py*.egg-info |
ef278603 | 131 | %endif |
8424aa58 | 132 | %{_examplesdir}/%{name}-%{version} |
d328d943 ER |
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 | |
f33c573b | 141 | %{_examplesdir}/python3-%{module}-%{version} |
d328d943 ER |
142 | %endif |
143 | ||
144 | %if %{with doc} | |
660096c2 | 145 | %files apidocs |
d328d943 ER |
146 | %defattr(644,root,root,755) |
147 | %doc docs/_build/html/* | |
148 | %endif |