2 # This is template for pure python modules (noarch)
3 # use template-specs/python-ext.spec for binary python packages
7 %bcond_without doc # don't build doc
8 %bcond_without tests # do not perform "make test"
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
26 Source0: https://files.pythonhosted.org/packages/source/M/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
28 #URL: https://pypi.python.org/pypi/MODULE
30 BuildRequires: rpm-pythonprov
31 BuildRequires: rpmbuild(macros) >= 1.714
33 BuildRequires: python-modules
34 BuildRequires: python-setuptools
37 BuildRequires: python3-modules
38 BuildRequires: python3-setuptools
40 # when using /usr/bin/env or other in-place substitutions
41 #BuildRequires: sed >= 4.0
42 # replace with other requires if defined in setup.py
43 Requires: python-modules
45 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
49 %description -l pl.UTF-8
51 %package -n python3-%{pypi_name}
54 Group: Libraries/Python
55 Requires: python3-modules
57 %description -n python3-%{pypi_name}
59 %description -n python3-%{pypi_name} -l pl.UTF-8
62 Summary: API documentation for Python %{module} module
63 Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module}
67 API documentation for Pythona %{module} module.
69 %description apidocs -l pl.UTF-8
70 Dokumentacja API modułu Pythona %{module}.
73 %setup -q -n %{pypi_name}-%{version}
75 # fix #!/usr/bin/env python -> #!/usr/bin/python:
76 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
80 %py_build %{?with_tests:test}
84 %py3_build %{?with_tests:test}
90 rm -rf _build/html/_sources
94 rm -rf $RPM_BUILD_ROOT
99 # when files are installed in other way that standard 'setup.py
100 # they need to be (re-)compiled
101 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
102 %py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
103 %py_comp $RPM_BUILD_ROOT%{py_sitedir}
112 # in case there are examples provided
114 install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
115 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
116 find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
117 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
120 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version}
121 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version}
122 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version} -name '*.py' \
123 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
127 rm -rf $RPM_BUILD_ROOT
131 %defattr(644,root,root,755)
132 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
133 %{py_sitescriptdir}/%{module}
134 %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
135 %{_examplesdir}/python-%{module}-%{version}
139 %files -n python3-%{pypi_name}
140 %defattr(644,root,root,755)
141 %doc AUTHORS CHANGES LICENSE
142 %{py3_sitescriptdir}/%{module}
143 %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
144 %{_examplesdir}/python3-%{pypi_name}-%{version}
149 %defattr(644,root,root,755)
150 %doc docs/_build/html/*