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