]>
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: |
3d5ea252 JB |
7 | %bcond_without doc # Sphinx documentation |
8 | %bcond_without tests # unit tests | |
0dd464e7 | 9 | %bcond_without python2 # CPython 2.x module |
d328d943 | 10 | %bcond_without python3 # CPython 3.x module |
4cdaa512 | 11 | |
643ec869 ER |
12 | # NOTES: |
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 | |
7170a7b1 ER |
19 | Summary: - |
20 | Summary(pl.UTF-8): - | |
2d5bfe82 | 21 | Name: python-%{module} |
7170a7b1 ER |
22 | Version: _ |
23 | Release: 0.1 | |
24 | License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here) | |
6177d217 | 25 | Group: Libraries/Python |
4b9c89b7 JB |
26 | # if pypi: |
27 | #Source0Download: https://pypi.org/simple/PYPI_NAME/ | |
28 | Source0: https://files.pythonhosted.org/packages/source/P/PYPI_NAME/%{pypi_name}-%{version}.tar.gz | |
7170a7b1 | 29 | # Source0-md5: - |
4b9c89b7 | 30 | #URL: https://pypi.org/project/PYPI_NAME/ |
7170a7b1 | 31 | URL: - |
0a48bf0d | 32 | BuildRequires: rpm-pythonprov |
038fedf4 | 33 | BuildRequires: rpmbuild(macros) >= 1.714 |
e3bbdd55 | 34 | %if %{with python2} |
4e897198 | 35 | BuildRequires: python-modules |
af55af9b | 36 | BuildRequires: python-setuptools |
e3bbdd55 | 37 | %endif |
d328d943 | 38 | %if %{with python3} |
d328d943 | 39 | BuildRequires: python3-modules |
af55af9b | 40 | BuildRequires: python3-setuptools |
d328d943 | 41 | %endif |
4e897198 JK |
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 | |
76f14f6a | 45 | Requires: python-modules |
4e897198 | 46 | BuildArch: noarch |
7170a7b1 ER |
47 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
48 | ||
49 | %description | |
50 | ||
e6f4b058 | 51 | %description -l pl.UTF-8 |
52 | ||
2d5bfe82 | 53 | %package -n python3-%{module} |
0dd464e7 JK |
54 | Summary: - |
55 | Summary(pl.UTF-8): - | |
56 | Group: Libraries/Python | |
76f14f6a | 57 | Requires: python3-modules |
0dd464e7 | 58 | |
2d5bfe82 | 59 | %description -n python3-%{module} |
0dd464e7 | 60 | |
2d5bfe82 | 61 | %description -n python3-%{module} -l pl.UTF-8 |
0dd464e7 | 62 | |
660096c2 | 63 | %package apidocs |
2bd7838d JB |
64 | Summary: API documentation for Python %{module} module |
65 | Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module} | |
d328d943 ER |
66 | Group: Documentation |
67 | ||
660096c2 | 68 | %description apidocs |
3dbbeb1f | 69 | API documentation for Python %{module} module. |
d328d943 | 70 | |
660096c2 | 71 | %description apidocs -l pl.UTF-8 |
2bd7838d | 72 | Dokumentacja API modułu Pythona %{module}. |
d328d943 | 73 | |
7170a7b1 | 74 | %prep |
643ec869 | 75 | %setup -q -n %{pypi_name}-%{version} |
7170a7b1 | 76 | |
5a020810 | 77 | # fix #!/usr/bin/env python -> #!/usr/bin/python: |
cb13b64b | 78 | #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py |
5a020810 | 79 | |
7170a7b1 | 80 | %build |
d328d943 | 81 | %if %{with python2} |
4e897198 | 82 | %py_build %{?with_tests:test} |
0dd464e7 | 83 | %endif |
a4ec70eb | 84 | |
d328d943 | 85 | %if %{with python3} |
4e897198 | 86 | %py3_build %{?with_tests:test} |
d328d943 ER |
87 | %endif |
88 | ||
89 | %if %{with doc} | |
90 | cd docs | |
91 | %{__make} -j1 html | |
92 | rm -rf _build/html/_sources | |
93 | %endif | |
94 | ||
7170a7b1 ER |
95 | %install |
96 | rm -rf $RPM_BUILD_ROOT | |
d328d943 ER |
97 | |
98 | %if %{with python2} | |
4e897198 | 99 | %py_install |
d328d943 | 100 | |
caefe7e7 ER |
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} | |
99f75e1c JB |
106 | |
107 | %py_postclean | |
d328d943 ER |
108 | %endif |
109 | ||
d328d943 | 110 | %if %{with python3} |
4e897198 | 111 | %py3_install |
d328d943 ER |
112 | %endif |
113 | ||
0dd464e7 JK |
114 | # in case there are examples provided |
115 | %if %{with python2} | |
3dbbeb1f JB |
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' \ | |
c7887ed1 | 119 | | xargs sed -i '1s|^#!.*python\b|#!%{__python}|' |
0dd464e7 JK |
120 | %endif |
121 | %if %{with python3} | |
b785d0c9 ER |
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' \ | |
073f936a | 125 | | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' |
0dd464e7 | 126 | %endif |
8424aa58 | 127 | |
7170a7b1 ER |
128 | %clean |
129 | rm -rf $RPM_BUILD_ROOT | |
130 | ||
0dd464e7 | 131 | %if %{with python2} |
7170a7b1 ER |
132 | %files |
133 | %defattr(644,root,root,755) | |
134 | %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO | |
4e897198 | 135 | %{py_sitescriptdir}/%{module} |
643ec869 | 136 | %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info |
3dbbeb1f | 137 | %{_examplesdir}/python-%{pypi_name}-%{version} |
d328d943 ER |
138 | %endif |
139 | ||
140 | %if %{with python3} | |
2d5bfe82 | 141 | %files -n python3-%{module} |
d328d943 ER |
142 | %defattr(644,root,root,755) |
143 | %doc AUTHORS CHANGES LICENSE | |
144 | %{py3_sitescriptdir}/%{module} | |
643ec869 | 145 | %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info |
b785d0c9 | 146 | %{_examplesdir}/python3-%{pypi_name}-%{version} |
d328d943 ER |
147 | %endif |
148 | ||
149 | %if %{with doc} | |
660096c2 | 150 | %files apidocs |
d328d943 ER |
151 | %defattr(644,root,root,755) |
152 | %doc docs/_build/html/* | |
153 | %endif |