]> git.pld-linux.org Git - projects/template-specs.git/blob - python.spec
a9994cc12b6b55c4e1fe355733faac3ab8a6992f
[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 %{__python} -m pytest ...
97 %endif
98 %endif
99
100 %if %{with python3}
101 %py3_build
102 # deprecated target, but sometimes still used: %{?with_tests:test}
103
104 %if %{with tests}
105 %{__python3} -m pytest ...
106 %endif
107 %endif
108
109 %if %{with doc}
110 %{__make} -C docs html
111 # if particular python version required - append:
112 #       SPHINXBUILD=sphinx-build-3
113 rm -rf docs/_build/html/_sources
114 %endif
115
116 %install
117 rm -rf $RPM_BUILD_ROOT
118
119 %if %{with python2}
120 %py_install
121
122 %if %{with enable_if_package_uses_non_standard_setup_py}
123 # when files are installed in other way that standard 'setup.py
124 # they need to be (re-)compiled
125 # change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
126 %py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
127 %py_comp $RPM_BUILD_ROOT%{py_sitedir}
128 %endif
129
130 %py_postclean
131 %endif
132
133 %if %{with python3}
134 %py3_install
135 %endif
136
137 %if %{with enable_if_there_are_examples_provided_in_package}
138 %if %{with python2}
139 install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
140 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
141 find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
142         | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
143 %endif
144 %if %{with python3}
145 install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
146 cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
147 find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
148         | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
149 %endif
150 %endif
151
152 %clean
153 rm -rf $RPM_BUILD_ROOT
154
155 %if %{with python2}
156 %files
157 %defattr(644,root,root,755)
158 %doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
159 %{py_sitescriptdir}/%{module}
160 %{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
161 %{_examplesdir}/python-%{module}-%{version}
162 %endif
163
164 %if %{with python3}
165 %files -n python3-%{module}
166 %defattr(644,root,root,755)
167 # copy %doc from python2 package here
168 %{py3_sitescriptdir}/%{module}
169 %{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
170 %{_examplesdir}/python3-%{module}-%{version}
171 %endif
172
173 %if %{with doc}
174 %files apidocs
175 %defattr(644,root,root,755)
176 %doc docs/_build/html/*
177 %endif
This page took 0.058865 seconds and 3 git commands to generate.