]> git.pld-linux.org Git - projects/template-specs.git/blame - python.spec
Add .tar.xz deps
[projects/template-specs.git] / python.spec
CommitLineData
4cdaa512 1#
367df2cb
JB
2# This is template for pure python2/python3 modules (noarch)
3# use template-specs/python3.spec for python3 only noarch packages
4e897198
JK
4# use template-specs/python-ext.spec for binary python packages
5#
6#
4cdaa512 7# Conditional build:
3d5ea252
JB
8%bcond_without doc # Sphinx documentation
9%bcond_without tests # unit tests
0dd464e7 10%bcond_without python2 # CPython 2.x module
d328d943 11%bcond_without python3 # CPython 3.x module
4cdaa512 12
643ec869
ER
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
7170a7b1
ER
20Summary: -
21Summary(pl.UTF-8): -
2d5bfe82 22Name: python-%{module}
7170a7b1
ER
23Version: _
24Release: 0.1
25License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
6177d217 26Group: Libraries/Python
4b9c89b7
JB
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
7170a7b1 30# Source0-md5: -
4b9c89b7 31#URL: https://pypi.org/project/PYPI_NAME/
7170a7b1 32URL: -
e3bbdd55 33%if %{with python2}
367df2cb 34BuildRequires: python-modules >= 1:2.5
af55af9b 35BuildRequires: python-setuptools
367df2cb
JB
36%if %{with tests}
37#BuildRequires: python-
38%endif
e3bbdd55 39%endif
d328d943 40%if %{with python3}
367df2cb 41BuildRequires: python3-modules >= 1:3.2
af55af9b 42BuildRequires: python3-setuptools
367df2cb
JB
43%if %{with tests}
44#BuildRequires: python3-
45%endif
d328d943 46%endif
367df2cb
JB
47BuildRequires: rpm-pythonprov
48BuildRequires: rpmbuild(macros) >= 1.714
4e897198
JK
49# when using /usr/bin/env or other in-place substitutions
50#BuildRequires: sed >= 4.0
367df2cb
JB
51%if %{with doc}
52BuildRequires: sphinx-pdg # -2 or -3
53%endif
4e897198 54# replace with other requires if defined in setup.py
367df2cb 55Requires: python-modules >= 1:2.5
4e897198 56BuildArch: noarch
7170a7b1
ER
57BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
58
59%description
60
e6f4b058 61%description -l pl.UTF-8
62
2d5bfe82 63%package -n python3-%{module}
0dd464e7
JK
64Summary: -
65Summary(pl.UTF-8): -
66Group: Libraries/Python
367df2cb 67Requires: python3-modules >= 1:3.2
0dd464e7 68
2d5bfe82 69%description -n python3-%{module}
0dd464e7 70
2d5bfe82 71%description -n python3-%{module} -l pl.UTF-8
0dd464e7 72
660096c2 73%package apidocs
2bd7838d
JB
74Summary: API documentation for Python %{module} module
75Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module}
d328d943
ER
76Group: Documentation
77
660096c2 78%description apidocs
3dbbeb1f 79API documentation for Python %{module} module.
d328d943 80
660096c2 81%description apidocs -l pl.UTF-8
2bd7838d 82Dokumentacja API modułu Pythona %{module}.
d328d943 83
7170a7b1 84%prep
643ec869 85%setup -q -n %{pypi_name}-%{version}
7170a7b1 86
5a020810 87# fix #!/usr/bin/env python -> #!/usr/bin/python:
cb13b64b 88#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
5a020810 89
7170a7b1 90%build
d328d943 91%if %{with python2}
367df2cb
JB
92%py_build
93# deprecated target, but sometimes still used: %{?with_tests:test}
94
95%if %{with tests}
96%{__python} -m pytest ...
97%endif
0dd464e7 98%endif
a4ec70eb 99
d328d943 100%if %{with python3}
367df2cb
JB
101%py3_build
102# deprecated target, but sometimes still used: %{?with_tests:test}
103
104%if %{with tests}
105%{__python3} -m pytest ...
106%endif
d328d943
ER
107%endif
108
109%if %{with doc}
367df2cb
JB
110%{__make} -C docs html
111# if particular python version required - append:
112# SPHINXBUILD=sphinx-build-3
113rm -rf docs/_build/html/_sources
d328d943
ER
114%endif
115
7170a7b1
ER
116%install
117rm -rf $RPM_BUILD_ROOT
d328d943
ER
118
119%if %{with python2}
4e897198 120%py_install
d328d943 121
367df2cb 122%if %{with enable_if_package_uses_non_standard_setup_py}
caefe7e7
ER
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}
367df2cb 128%endif
99f75e1c
JB
129
130%py_postclean
d328d943
ER
131%endif
132
d328d943 133%if %{with python3}
4e897198 134%py3_install
d328d943
ER
135%endif
136
367df2cb 137%if %{with enable_if_there_are_examples_provided_in_package}
0dd464e7 138%if %{with python2}
1ce44770
JB
139install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
140cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
141find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
c7887ed1 142 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
0dd464e7
JK
143%endif
144%if %{with python3}
1ce44770
JB
145install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
146cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
147find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
073f936a 148 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
0dd464e7 149%endif
367df2cb 150%endif
8424aa58 151
7170a7b1
ER
152%clean
153rm -rf $RPM_BUILD_ROOT
154
0dd464e7 155%if %{with python2}
7170a7b1
ER
156%files
157%defattr(644,root,root,755)
158%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
4e897198 159%{py_sitescriptdir}/%{module}
643ec869 160%{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
1ce44770 161%{_examplesdir}/python-%{module}-%{version}
d328d943
ER
162%endif
163
164%if %{with python3}
2d5bfe82 165%files -n python3-%{module}
d328d943 166%defattr(644,root,root,755)
331aa1fb 167# copy %doc from python2 package here
d328d943 168%{py3_sitescriptdir}/%{module}
643ec869 169%{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
1ce44770 170%{_examplesdir}/python3-%{module}-%{version}
d328d943
ER
171%endif
172
173%if %{with doc}
660096c2 174%files apidocs
d328d943
ER
175%defattr(644,root,root,755)
176%doc docs/_build/html/*
177%endif
This page took 0.561619 seconds and 4 git commands to generate.