]>
Commit | Line | Data |
---|---|---|
4cdaa512 | 1 | # |
367df2cb JB |
2 | # This is template for pure python2/python3 modules (noarch) |
3 | # use template-specs/python3.spec for python3 only noarch packages | |
4e897198 JK |
4 | # use template-specs/python-ext.spec for binary python packages |
5 | # | |
6 | # | |
4cdaa512 | 7 | # Conditional build: |
3d5ea252 JB |
8 | %bcond_without doc # Sphinx documentation |
9 | %bcond_without tests # unit tests | |
0dd464e7 | 10 | %bcond_without python2 # CPython 2.x module |
d328d943 | 11 | %bcond_without python3 # CPython 3.x module |
4cdaa512 | 12 | |
643ec869 ER |
13 | # NOTES: |
14 | # - 'module' should match the Python import path (first component?) | |
15 | # - 'egg_name' should equal to Python egg name | |
16 | # - 'pypi_name' must match the Python Package Index name | |
17 | %define module crispy_forms | |
18 | %define egg_name django_crispy_forms | |
19 | %define pypi_name django-crispy-forms | |
7170a7b1 ER |
20 | Summary: - |
21 | Summary(pl.UTF-8): - | |
2d5bfe82 | 22 | Name: python-%{module} |
7170a7b1 ER |
23 | Version: _ |
24 | Release: 0.1 | |
25 | License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here) | |
6177d217 | 26 | Group: Libraries/Python |
4b9c89b7 JB |
27 | # if pypi: |
28 | #Source0Download: https://pypi.org/simple/PYPI_NAME/ | |
29 | Source0: https://files.pythonhosted.org/packages/source/P/PYPI_NAME/%{pypi_name}-%{version}.tar.gz | |
7170a7b1 | 30 | # Source0-md5: - |
4b9c89b7 | 31 | #URL: https://pypi.org/project/PYPI_NAME/ |
7170a7b1 | 32 | URL: - |
e3bbdd55 | 33 | %if %{with python2} |
367df2cb | 34 | BuildRequires: python-modules >= 1:2.5 |
af55af9b | 35 | BuildRequires: python-setuptools |
367df2cb JB |
36 | %if %{with tests} |
37 | #BuildRequires: python- | |
38 | %endif | |
e3bbdd55 | 39 | %endif |
d328d943 | 40 | %if %{with python3} |
367df2cb | 41 | BuildRequires: python3-modules >= 1:3.2 |
af55af9b | 42 | BuildRequires: python3-setuptools |
367df2cb JB |
43 | %if %{with tests} |
44 | #BuildRequires: python3- | |
45 | %endif | |
d328d943 | 46 | %endif |
367df2cb JB |
47 | BuildRequires: rpm-pythonprov |
48 | BuildRequires: rpmbuild(macros) >= 1.714 | |
4e897198 JK |
49 | # when using /usr/bin/env or other in-place substitutions |
50 | #BuildRequires: sed >= 4.0 | |
367df2cb JB |
51 | %if %{with doc} |
52 | BuildRequires: sphinx-pdg # -2 or -3 | |
53 | %endif | |
4e897198 | 54 | # replace with other requires if defined in setup.py |
367df2cb | 55 | Requires: python-modules >= 1:2.5 |
4e897198 | 56 | BuildArch: noarch |
7170a7b1 ER |
57 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
58 | ||
59 | %description | |
60 | ||
e6f4b058 | 61 | %description -l pl.UTF-8 |
62 | ||
2d5bfe82 | 63 | %package -n python3-%{module} |
0dd464e7 JK |
64 | Summary: - |
65 | Summary(pl.UTF-8): - | |
66 | Group: Libraries/Python | |
367df2cb | 67 | Requires: python3-modules >= 1:3.2 |
0dd464e7 | 68 | |
2d5bfe82 | 69 | %description -n python3-%{module} |
0dd464e7 | 70 | |
2d5bfe82 | 71 | %description -n python3-%{module} -l pl.UTF-8 |
0dd464e7 | 72 | |
660096c2 | 73 | %package apidocs |
2bd7838d JB |
74 | Summary: API documentation for Python %{module} module |
75 | Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module} | |
d328d943 ER |
76 | Group: Documentation |
77 | ||
660096c2 | 78 | %description apidocs |
3dbbeb1f | 79 | API documentation for Python %{module} module. |
d328d943 | 80 | |
660096c2 | 81 | %description apidocs -l pl.UTF-8 |
2bd7838d | 82 | Dokumentacja API modułu Pythona %{module}. |
d328d943 | 83 | |
7170a7b1 | 84 | %prep |
643ec869 | 85 | %setup -q -n %{pypi_name}-%{version} |
7170a7b1 | 86 | |
5a020810 | 87 | # fix #!/usr/bin/env python -> #!/usr/bin/python: |
cb13b64b | 88 | #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py |
5a020810 | 89 | |
7170a7b1 | 90 | %build |
d328d943 | 91 | %if %{with python2} |
367df2cb JB |
92 | %py_build |
93 | # deprecated target, but sometimes still used: %{?with_tests:test} | |
94 | ||
95 | %if %{with tests} | |
7302396e JB |
96 | # use explicit plugins list for reliable builds (delete PYTEST_PLUGINS if empty) |
97 | PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \ | |
98 | PYTEST_PLUGINS= \ | |
367df2cb JB |
99 | %{__python} -m pytest ... |
100 | %endif | |
0dd464e7 | 101 | %endif |
a4ec70eb | 102 | |
d328d943 | 103 | %if %{with python3} |
367df2cb JB |
104 | %py3_build |
105 | # deprecated target, but sometimes still used: %{?with_tests:test} | |
106 | ||
107 | %if %{with tests} | |
7302396e JB |
108 | # use explicit plugins list for reliable builds (delete PYTEST_PLUGINS if empty) |
109 | PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \ | |
110 | PYTEST_PLUGINS= \ | |
367df2cb JB |
111 | %{__python3} -m pytest ... |
112 | %endif | |
d328d943 ER |
113 | %endif |
114 | ||
115 | %if %{with doc} | |
367df2cb JB |
116 | %{__make} -C docs html |
117 | # if particular python version required - append: | |
118 | # SPHINXBUILD=sphinx-build-3 | |
119 | rm -rf docs/_build/html/_sources | |
d328d943 ER |
120 | %endif |
121 | ||
7170a7b1 ER |
122 | %install |
123 | rm -rf $RPM_BUILD_ROOT | |
d328d943 ER |
124 | |
125 | %if %{with python2} | |
4e897198 | 126 | %py_install |
d328d943 | 127 | |
367df2cb | 128 | %if %{with enable_if_package_uses_non_standard_setup_py} |
caefe7e7 ER |
129 | # when files are installed in other way that standard 'setup.py |
130 | # they need to be (re-)compiled | |
131 | # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages! | |
132 | %py_ocomp $RPM_BUILD_ROOT%{py_sitedir} | |
133 | %py_comp $RPM_BUILD_ROOT%{py_sitedir} | |
367df2cb | 134 | %endif |
99f75e1c JB |
135 | |
136 | %py_postclean | |
d328d943 ER |
137 | %endif |
138 | ||
d328d943 | 139 | %if %{with python3} |
4e897198 | 140 | %py3_install |
d328d943 ER |
141 | %endif |
142 | ||
367df2cb | 143 | %if %{with enable_if_there_are_examples_provided_in_package} |
0dd464e7 | 144 | %if %{with python2} |
1ce44770 JB |
145 | install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} |
146 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} | |
147 | find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \ | |
c7887ed1 | 148 | | xargs sed -i '1s|^#!.*python\b|#!%{__python}|' |
0dd464e7 JK |
149 | %endif |
150 | %if %{with python3} | |
1ce44770 JB |
151 | install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} |
152 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
153 | find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \ | |
073f936a | 154 | | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' |
0dd464e7 | 155 | %endif |
367df2cb | 156 | %endif |
8424aa58 | 157 | |
7170a7b1 ER |
158 | %clean |
159 | rm -rf $RPM_BUILD_ROOT | |
160 | ||
0dd464e7 | 161 | %if %{with python2} |
7170a7b1 ER |
162 | %files |
163 | %defattr(644,root,root,755) | |
164 | %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO | |
4e897198 | 165 | %{py_sitescriptdir}/%{module} |
643ec869 | 166 | %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info |
1ce44770 | 167 | %{_examplesdir}/python-%{module}-%{version} |
d328d943 ER |
168 | %endif |
169 | ||
170 | %if %{with python3} | |
2d5bfe82 | 171 | %files -n python3-%{module} |
d328d943 | 172 | %defattr(644,root,root,755) |
331aa1fb | 173 | # copy %doc from python2 package here |
d328d943 | 174 | %{py3_sitescriptdir}/%{module} |
643ec869 | 175 | %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info |
1ce44770 | 176 | %{_examplesdir}/python3-%{module}-%{version} |
d328d943 ER |
177 | %endif |
178 | ||
179 | %if %{with doc} | |
660096c2 | 180 | %files apidocs |
d328d943 ER |
181 | %defattr(644,root,root,755) |
182 | %doc docs/_build/html/* | |
183 | %endif |