]>
Commit | Line | Data |
---|---|---|
1 | # | |
2 | # This is template for pure python modules (noarch) | |
3 | # use template-specs/python-ext.spec for binary python packages | |
4 | # | |
5 | # | |
6 | # Conditional build: | |
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 | |
11 | ||
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 | |
19 | Summary: - | |
20 | Summary(pl.UTF-8): - | |
21 | Name: python-%{module} | |
22 | Version: _ | |
23 | Release: 0.1 | |
24 | License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here) | |
25 | Group: Libraries/Python | |
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 | |
29 | # Source0-md5: - | |
30 | #URL: https://pypi.org/project/PYPI_NAME/ | |
31 | URL: - | |
32 | BuildRequires: rpm-pythonprov | |
33 | BuildRequires: rpmbuild(macros) >= 1.714 | |
34 | %if %{with python2} | |
35 | BuildRequires: python-modules | |
36 | BuildRequires: python-setuptools | |
37 | %endif | |
38 | %if %{with python3} | |
39 | BuildRequires: python3-modules | |
40 | BuildRequires: python3-setuptools | |
41 | %endif | |
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 | |
46 | BuildArch: noarch | |
47 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
48 | ||
49 | %description | |
50 | ||
51 | %description -l pl.UTF-8 | |
52 | ||
53 | %package -n python3-%{module} | |
54 | Summary: - | |
55 | Summary(pl.UTF-8): - | |
56 | Group: Libraries/Python | |
57 | Requires: python3-modules | |
58 | ||
59 | %description -n python3-%{module} | |
60 | ||
61 | %description -n python3-%{module} -l pl.UTF-8 | |
62 | ||
63 | %package apidocs | |
64 | Summary: API documentation for Python %{module} module | |
65 | Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module} | |
66 | Group: Documentation | |
67 | ||
68 | %description apidocs | |
69 | API documentation for Python %{module} module. | |
70 | ||
71 | %description apidocs -l pl.UTF-8 | |
72 | Dokumentacja API modułu Pythona %{module}. | |
73 | ||
74 | %prep | |
75 | %setup -q -n %{pypi_name}-%{version} | |
76 | ||
77 | # fix #!/usr/bin/env python -> #!/usr/bin/python: | |
78 | #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py | |
79 | ||
80 | %build | |
81 | %if %{with python2} | |
82 | %py_build %{?with_tests:test} | |
83 | %endif | |
84 | ||
85 | %if %{with python3} | |
86 | %py3_build %{?with_tests:test} | |
87 | %endif | |
88 | ||
89 | %if %{with doc} | |
90 | cd docs | |
91 | %{__make} -j1 html | |
92 | rm -rf _build/html/_sources | |
93 | %endif | |
94 | ||
95 | %install | |
96 | rm -rf $RPM_BUILD_ROOT | |
97 | ||
98 | %if %{with python2} | |
99 | %py_install | |
100 | ||
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} | |
106 | ||
107 | %py_postclean | |
108 | %endif | |
109 | ||
110 | %if %{with python3} | |
111 | %py3_install | |
112 | %endif | |
113 | ||
114 | # in case there are examples provided | |
115 | %if %{with python2} | |
116 | install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} | |
117 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} | |
118 | find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \ | |
119 | | xargs sed -i '1s|^#!.*python\b|#!%{__python}|' | |
120 | %endif | |
121 | %if %{with python3} | |
122 | install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
123 | cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} | |
124 | find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \ | |
125 | | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|' | |
126 | %endif | |
127 | ||
128 | %clean | |
129 | rm -rf $RPM_BUILD_ROOT | |
130 | ||
131 | %if %{with python2} | |
132 | %files | |
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-%{module}-%{version} | |
138 | %endif | |
139 | ||
140 | %if %{with python3} | |
141 | %files -n python3-%{module} | |
142 | %defattr(644,root,root,755) | |
143 | # copy %doc from python2 package here | |
144 | %{py3_sitescriptdir}/%{module} | |
145 | %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info | |
146 | %{_examplesdir}/python3-%{module}-%{version} | |
147 | %endif | |
148 | ||
149 | %if %{with doc} | |
150 | %files apidocs | |
151 | %defattr(644,root,root,755) | |
152 | %doc docs/_build/html/* | |
153 | %endif |