2 # This is template for pure python2/python3 modules (noarch)
3 # use template-specs/python3.spec for python3 only noarch packages
4 # use template-specs/python-ext.spec for binary python packages
8 %bcond_without doc # Sphinx documentation
9 %bcond_without tests # unit tests
10 %bcond_without python2 # CPython 2.x module
11 %bcond_without python3 # CPython 3.x module
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
22 Name: python-%{module}
25 License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
26 Group: Libraries/Python
28 #Source0Download: https://pypi.org/simple/PYPI_NAME/
29 Source0: https://files.pythonhosted.org/packages/source/P/PYPI_NAME/%{pypi_name}-%{version}.tar.gz
31 #URL: https://pypi.org/project/PYPI_NAME/
34 BuildRequires: python-modules >= 1:2.5
35 BuildRequires: python-setuptools
37 #BuildRequires: python-
41 BuildRequires: python3-modules >= 1:3.2
42 BuildRequires: python3-setuptools
44 #BuildRequires: python3-
47 BuildRequires: rpm-pythonprov
48 BuildRequires: rpmbuild(macros) >= 1.714
49 # when using /usr/bin/env or other in-place substitutions
50 #BuildRequires: sed >= 4.0
52 BuildRequires: sphinx-pdg # -2 or -3
54 # replace with other requires if defined in setup.py
55 Requires: python-modules >= 1:2.5
57 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
61 %description -l pl.UTF-8
63 %package -n python3-%{module}
66 Group: Libraries/Python
67 Requires: python3-modules >= 1:3.2
69 %description -n python3-%{module}
71 %description -n python3-%{module} -l pl.UTF-8
74 Summary: API documentation for Python %{module} module
75 Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module}
79 API documentation for Python %{module} module.
81 %description apidocs -l pl.UTF-8
82 Dokumentacja API modułu Pythona %{module}.
85 %setup -q -n %{pypi_name}-%{version}
87 # fix #!/usr/bin/env python -> #!/usr/bin/python:
88 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
93 # deprecated target, but sometimes still used: %{?with_tests:test}
96 %{__python} -m pytest ...
102 # deprecated target, but sometimes still used: %{?with_tests:test}
105 %{__python3} -m pytest ...
110 %{__make} -C docs html
111 # if particular python version required - append:
112 # SPHINXBUILD=sphinx-build-3
113 rm -rf docs/_build/html/_sources
117 rm -rf $RPM_BUILD_ROOT
122 %if %{with enable_if_package_uses_non_standard_setup_py}
123 # when files are installed in other way that standard 'setup.py
124 # they need to be (re-)compiled
125 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
126 %py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
127 %py_comp $RPM_BUILD_ROOT%{py_sitedir}
137 %if %{with enable_if_there_are_examples_provided_in_package}
139 install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
140 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
141 find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
142 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
145 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
146 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
147 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
148 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
153 rm -rf $RPM_BUILD_ROOT
157 %defattr(644,root,root,755)
158 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
159 %{py_sitescriptdir}/%{module}
160 %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
161 %{_examplesdir}/python-%{module}-%{version}
165 %files -n python3-%{module}
166 %defattr(644,root,root,755)
167 # copy %doc from python2 package here
168 %{py3_sitescriptdir}/%{module}
169 %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
170 %{_examplesdir}/python3-%{module}-%{version}
175 %defattr(644,root,root,755)
176 %doc docs/_build/html/*