]>
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 | |
b81eefa5 | 12 | %define module template |
7170a7b1 ER |
13 | Summary: - |
14 | Summary(pl.UTF-8): - | |
3256a2f0 | 15 | # Name must match the python module/package name (as in 'import' statement) |
b81eefa5 | 16 | Name: python-%{module} |
7170a7b1 ER |
17 | Version: _ |
18 | Release: 0.1 | |
19 | License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here) | |
6177d217 | 20 | Group: Libraries/Python |
4e897198 | 21 | Source0: https://pypi.python.org/packages/source/M/MODULE/%{module}-%{version}.tar.gz |
7170a7b1 | 22 | # Source0-md5: - |
4e897198 | 23 | #URL: https://pypi.python.org/pypi/MODULE |
7170a7b1 | 24 | URL: - |
0a48bf0d | 25 | BuildRequires: rpm-pythonprov |
4e897198 | 26 | # for the py_build, py_install macros |
511e30a6 | 27 | BuildRequires: rpmbuild(macros) >= 1.713 |
e3bbdd55 | 28 | %if %{with python2} |
4e897198 JK |
29 | BuildRequires: python-modules |
30 | #BuildRequires: python-setuptools | |
e3bbdd55 | 31 | %endif |
d328d943 | 32 | %if %{with python3} |
d328d943 | 33 | BuildRequires: python3-modules |
4e897198 | 34 | #BuildRequires: python3-setuptools |
d328d943 | 35 | %endif |
4e897198 JK |
36 | # when using /usr/bin/env or other in-place substitutions |
37 | #BuildRequires: sed >= 4.0 | |
38 | # replace with other requires if defined in setup.py | |
76f14f6a | 39 | Requires: python-modules |
4e897198 | 40 | BuildArch: noarch |
7170a7b1 ER |
41 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
42 | ||
43 | %description | |
44 | ||
e6f4b058 | 45 | %description -l pl.UTF-8 |
46 | ||
0dd464e7 JK |
47 | %package -n python3-%{module} |
48 | Summary: - | |
49 | Summary(pl.UTF-8): - | |
50 | Group: Libraries/Python | |
76f14f6a | 51 | Requires: python3-modules |
0dd464e7 JK |
52 | |
53 | %description -n python3-%{module} | |
54 | ||
55 | %description -n python3-%{module} -l pl.UTF-8 | |
56 | ||
660096c2 | 57 | %package apidocs |
d328d943 ER |
58 | Summary: %{module} API documentation |
59 | Summary(pl.UTF-8): Dokumentacja API %{module} | |
60 | Group: Documentation | |
61 | ||
660096c2 | 62 | %description apidocs |
d328d943 ER |
63 | API documentation for %{module}. |
64 | ||
660096c2 | 65 | %description apidocs -l pl.UTF-8 |
d328d943 ER |
66 | Dokumentacja API %{module}. |
67 | ||
7170a7b1 | 68 | %prep |
641675c1 | 69 | %setup -q -n %{module}-%{version} |
7170a7b1 | 70 | |
5a020810 | 71 | # fix #!/usr/bin/env python -> #!/usr/bin/python: |
cb13b64b | 72 | #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py |
5a020810 | 73 | |
7170a7b1 | 74 | %build |
d328d943 | 75 | %if %{with python2} |
4e897198 | 76 | %py_build %{?with_tests:test} |
0dd464e7 | 77 | %endif |
a4ec70eb | 78 | |
d328d943 | 79 | %if %{with python3} |
4e897198 | 80 | %py3_build %{?with_tests:test} |
d328d943 ER |
81 | %endif |
82 | ||
83 | %if %{with doc} | |
84 | cd docs | |
85 | %{__make} -j1 html | |
86 | rm -rf _build/html/_sources | |
87 | %endif | |
88 | ||
7170a7b1 ER |
89 | %install |
90 | rm -rf $RPM_BUILD_ROOT | |
d328d943 ER |
91 | |
92 | %if %{with python2} | |
4e897198 | 93 | %py_install |
d328d943 ER |
94 | |
95 | %py_postclean | |
96 | %endif | |
97 | ||
d328d943 | 98 | %if %{with python3} |
4e897198 | 99 | %py3_install |
d328d943 ER |
100 | %endif |
101 | ||
0dd464e7 JK |
102 | # in case there are examples provided |
103 | %if %{with python2} | |
104 | install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} | |
105 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version} | |
106 | %endif | |
107 | %if %{with python3} | |
f33c573b JK |
108 | install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} |
109 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
110 | find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \ | |
073f936a | 111 | | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' |
0dd464e7 | 112 | %endif |
8424aa58 | 113 | |
7170a7b1 ER |
114 | %clean |
115 | rm -rf $RPM_BUILD_ROOT | |
116 | ||
0dd464e7 | 117 | %if %{with python2} |
7170a7b1 ER |
118 | %files |
119 | %defattr(644,root,root,755) | |
120 | %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO | |
4e897198 | 121 | %{py_sitescriptdir}/%{module} |
ef0b62a1 | 122 | %if "%{py_ver}" > "2.4" |
4e897198 | 123 | %{py_sitescriptdir}/%{module}-%{version}-py*.egg-info |
ef278603 | 124 | %endif |
8424aa58 | 125 | %{_examplesdir}/%{name}-%{version} |
d328d943 ER |
126 | %endif |
127 | ||
128 | %if %{with python3} | |
129 | %files -n python3-%{module} | |
130 | %defattr(644,root,root,755) | |
131 | %doc AUTHORS CHANGES LICENSE | |
132 | %{py3_sitescriptdir}/%{module} | |
133 | %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info | |
f33c573b | 134 | %{_examplesdir}/python3-%{module}-%{version} |
d328d943 ER |
135 | %endif |
136 | ||
137 | %if %{with doc} | |
660096c2 | 138 | %files apidocs |
d328d943 ER |
139 | %defattr(644,root,root,755) |
140 | %doc docs/_build/html/* | |
141 | %endif |