2 # This is template for pure python modules (noarch)
3 # use template-specs/python-ext.spec for binary python packages
7 %bcond_without doc # Sphinx documentation
8 %bcond_without tests # unit tests
9 %bcond_without python2 # CPython 2.x module
10 %bcond_without python3 # CPython 3.x module
13 # - 'module' should match the Python import path (first component?)
14 # - 'egg_name' should equal to Python egg name
15 # - 'pypi_name' must match the Python Package Index name
16 %define module crispy_forms
17 %define egg_name django_crispy_forms
18 %define pypi_name django-crispy-forms
21 Name: python-%{pypi_name}
24 License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
25 Group: Libraries/Python
27 #Source0Download: https://pypi.org/simple/PYPI_NAME/
28 Source0: https://files.pythonhosted.org/packages/source/P/PYPI_NAME/%{pypi_name}-%{version}.tar.gz
30 #URL: https://pypi.org/project/PYPI_NAME/
32 BuildRequires: rpm-pythonprov
33 BuildRequires: rpmbuild(macros) >= 1.714
35 BuildRequires: python-modules
36 BuildRequires: python-setuptools
39 BuildRequires: python3-modules
40 BuildRequires: python3-setuptools
42 # when using /usr/bin/env or other in-place substitutions
43 #BuildRequires: sed >= 4.0
44 # replace with other requires if defined in setup.py
45 Requires: python-modules
47 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
51 %description -l pl.UTF-8
53 %package -n python3-%{pypi_name}
56 Group: Libraries/Python
57 Requires: python3-modules
59 %description -n python3-%{pypi_name}
61 %description -n python3-%{pypi_name} -l pl.UTF-8
64 Summary: API documentation for Python %{module} module
65 Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module}
69 API documentation for Python %{module} module.
71 %description apidocs -l pl.UTF-8
72 Dokumentacja API modułu Pythona %{module}.
75 %setup -q -n %{pypi_name}-%{version}
77 # fix #!/usr/bin/env python -> #!/usr/bin/python:
78 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
82 %py_build %{?with_tests:test}
86 %py3_build %{?with_tests:test}
92 rm -rf _build/html/_sources
96 rm -rf $RPM_BUILD_ROOT
101 # when files are installed in other way that standard 'setup.py
102 # they need to be (re-)compiled
103 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
104 %py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
105 %py_comp $RPM_BUILD_ROOT%{py_sitedir}
114 # in case there are examples provided
116 install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{pypi_name}-%{version}
117 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{pypi_name}-%{version}
118 find $RPM_BUILD_ROOT%{_examplesdir}/python-%{pypi_name}-%{version} -name '*.py' \
119 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
122 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version}
123 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version}
124 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version} -name '*.py' \
125 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
129 rm -rf $RPM_BUILD_ROOT
133 %defattr(644,root,root,755)
134 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
135 %{py_sitescriptdir}/%{module}
136 %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
137 %{_examplesdir}/python-%{pypi_name}-%{version}
141 %files -n python3-%{pypi_name}
142 %defattr(644,root,root,755)
143 %doc AUTHORS CHANGES LICENSE
144 %{py3_sitescriptdir}/%{module}
145 %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
146 %{_examplesdir}/python3-%{pypi_name}-%{version}
151 %defattr(644,root,root,755)
152 %doc docs/_build/html/*