]> git.pld-linux.org Git - projects/template-specs.git/blob - python.spec
dokuwiki-plugin.spec: Fix packaging languages with rpm 4.12
[projects/template-specs.git] / python.spec
1 #
2 # This is template for pure python2/python3 modules (noarch)
3 # use template-specs/python3.spec for python3 only noarch packages
4 # use template-specs/python-ext.spec for binary python packages
5 #
6 #
7 # Conditional build:
8 %bcond_without  doc     # Sphinx documentation
9 %bcond_without  tests   # unit tests
10 %bcond_without  python2 # CPython 2.x module
11 %bcond_without  python3 # CPython 3.x module
12
13 # NOTES:
14 # - 'module' should match the Python import path (first component?)
15 # - 'egg_name' should equal to Python egg name
16 # - 'pypi_name' must match the Python Package Index name
17 %define         module          crispy_forms
18 %define         egg_name        django_crispy_forms
19 %define         pypi_name       django-crispy-forms
20 Summary:        -
21 Summary(pl.UTF-8):      -
22 Name:           python-%{module}
23 Version:        _
24 Release:        0.1
25 License:        - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
26 Group:          Libraries/Python
27 # if pypi:
28 #Source0Download: https://pypi.org/simple/PYPI_NAME/
29 Source0:        https://files.pythonhosted.org/packages/source/P/PYPI_NAME/%{pypi_name}-%{version}.tar.gz
30 # Source0-md5:  -
31 #URL:           https://pypi.org/project/PYPI_NAME/
32 URL:            -
33 %if %{with python2}
34 BuildRequires:  python-modules >= 1:2.5
35 BuildRequires:  python-setuptools
36 %if %{with tests}
37 #BuildRequires: python-
38 %endif
39 %endif
40 %if %{with python3}
41 BuildRequires:  python3-modules >= 1:3.2
42 BuildRequires:  python3-setuptools
43 %if %{with tests}
44 #BuildRequires: python3-
45 %endif
46 %endif
47 BuildRequires:  rpm-pythonprov
48 BuildRequires:  rpmbuild(macros) >= 1.714
49 # when using /usr/bin/env or other in-place substitutions
50 #BuildRequires:        sed >= 4.0
51 %if %{with doc}
52 BuildRequires:  sphinx-pdg # -2 or -3
53 %endif
54 # replace with other requires if defined in setup.py
55 Requires:       python-modules >= 1:2.5
56 BuildArch:      noarch
57 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
58
59 %description
60
61 %description -l pl.UTF-8
62
63 %package -n python3-%{module}
64 Summary:        -
65 Summary(pl.UTF-8):      -
66 Group:          Libraries/Python
67 Requires:       python3-modules >= 1:3.2
68
69 %description -n python3-%{module}
70
71 %description -n python3-%{module} -l pl.UTF-8
72
73 %package apidocs
74 Summary:        API documentation for Python %{module} module
75 Summary(pl.UTF-8):      Dokumentacja API modułu Pythona %{module}
76 Group:          Documentation
77
78 %description apidocs
79 API documentation for Python %{module} module.
80
81 %description apidocs -l pl.UTF-8
82 Dokumentacja API modułu Pythona %{module}.
83
84 %prep
85 %setup -q -n %{pypi_name}-%{version}
86
87 # fix #!/usr/bin/env python -> #!/usr/bin/python:
88 #%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
89
90 %build
91 %if %{with python2}
92 %py_build
93 # deprecated target, but sometimes still used: %{?with_tests:test}
94
95 %if %{with tests}
96 # use explicit plugins list for reliable builds (delete PYTEST_PLUGINS if empty)
97 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
98 PYTEST_PLUGINS= \
99 %{__python} -m pytest ...
100 %endif
101 %endif
102
103 %if %{with python3}
104 %py3_build
105 # deprecated target, but sometimes still used: %{?with_tests:test}
106
107 %if %{with tests}
108 # use explicit plugins list for reliable builds (delete PYTEST_PLUGINS if empty)
109 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
110 PYTEST_PLUGINS= \
111 %{__python3} -m pytest ...
112 %endif
113 %endif
114
115 %if %{with doc}
116 %{__make} -C docs html
117 # if particular python version required - append:
118 #       SPHINXBUILD=sphinx-build-3
119 rm -rf docs/_build/html/_sources
120 %endif
121
122 %install
123 rm -rf $RPM_BUILD_ROOT
124
125 %if %{with python2}
126 %py_install
127
128 %if %{with enable_if_package_uses_non_standard_setup_py}
129 # when files are installed in other way that standard 'setup.py
130 # they need to be (re-)compiled
131 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
132 %py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
133 %py_comp $RPM_BUILD_ROOT%{py_sitedir}
134 %endif
135
136 %py_postclean
137 %endif
138
139 %if %{with python3}
140 %py3_install
141 %endif
142
143 %if %{with enable_if_there_are_examples_provided_in_package}
144 %if %{with python2}
145 install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
146 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
147 find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
148         | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
149 %endif
150 %if %{with python3}
151 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
152 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
153 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
154         | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
155 %endif
156 %endif
157
158 %clean
159 rm -rf $RPM_BUILD_ROOT
160
161 %if %{with python2}
162 %files
163 %defattr(644,root,root,755)
164 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
165 %{py_sitescriptdir}/%{module}
166 %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
167 %{_examplesdir}/python-%{module}-%{version}
168 %endif
169
170 %if %{with python3}
171 %files -n python3-%{module}
172 %defattr(644,root,root,755)
173 # copy %doc from python2 package here
174 %{py3_sitescriptdir}/%{module}
175 %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
176 %{_examplesdir}/python3-%{module}-%{version}
177 %endif
178
179 %if %{with doc}
180 %files apidocs
181 %defattr(644,root,root,755)
182 %doc docs/_build/html/*
183 %endif
This page took 0.045841 seconds and 4 git commands to generate.