]> git.pld-linux.org Git - projects/template-specs.git/blame_incremental - python.spec
dokuwiki-plugin.spec: Fix packaging languages with rpm 4.12
[projects/template-specs.git] / python.spec
... / ...
CommitLineData
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
20Summary: -
21Summary(pl.UTF-8): -
22Name: python-%{module}
23Version: _
24Release: 0.1
25License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
26Group: Libraries/Python
27# if pypi:
28#Source0Download: https://pypi.org/simple/PYPI_NAME/
29Source0: 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/
32URL: -
33%if %{with python2}
34BuildRequires: python-modules >= 1:2.5
35BuildRequires: python-setuptools
36%if %{with tests}
37#BuildRequires: python-
38%endif
39%endif
40%if %{with python3}
41BuildRequires: python3-modules >= 1:3.2
42BuildRequires: python3-setuptools
43%if %{with tests}
44#BuildRequires: python3-
45%endif
46%endif
47BuildRequires: rpm-pythonprov
48BuildRequires: rpmbuild(macros) >= 1.714
49# when using /usr/bin/env or other in-place substitutions
50#BuildRequires: sed >= 4.0
51%if %{with doc}
52BuildRequires: sphinx-pdg # -2 or -3
53%endif
54# replace with other requires if defined in setup.py
55Requires: python-modules >= 1:2.5
56BuildArch: noarch
57BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
58
59%description
60
61%description -l pl.UTF-8
62
63%package -n python3-%{module}
64Summary: -
65Summary(pl.UTF-8): -
66Group: Libraries/Python
67Requires: 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
74Summary: API documentation for Python %{module} module
75Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module}
76Group: Documentation
77
78%description apidocs
79API documentation for Python %{module} module.
80
81%description apidocs -l pl.UTF-8
82Dokumentacja 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)
97PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
98PYTEST_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)
109PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
110PYTEST_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
119rm -rf docs/_build/html/_sources
120%endif
121
122%install
123rm -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}
145install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
146cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
147find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
148 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
149%endif
150%if %{with python3}
151install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
152cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
153find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
154 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
155%endif
156%endif
157
158%clean
159rm -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.119238 seconds and 5 git commands to generate.