]> git.pld-linux.org Git - projects/template-specs.git/blame - python.spec
pecl: add example how to make failed tests as XFAIL
[projects/template-specs.git] / python.spec
CommitLineData
4cdaa512 1#
4e897198
JK
2# This is template for pure python modules (noarch)
3# use template-specs/python-ext.spec for binary python packages
4#
5#
4cdaa512 6# Conditional build:
4e897198 7%bcond_without doc # don't build doc
4cdaa512 8%bcond_without tests # do not perform "make test"
0dd464e7 9%bcond_without python2 # CPython 2.x module
d328d943 10%bcond_without python3 # CPython 3.x module
4cdaa512 11
643ec869
ER
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
7170a7b1
ER
19Summary: -
20Summary(pl.UTF-8): -
643ec869 21Name: python-%{pypi_name}
7170a7b1
ER
22Version: _
23Release: 0.1
24License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
6177d217 25Group: Libraries/Python
d147b63c 26Source0: https://files.pythonhosted.org/packages/source/M/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
7170a7b1 27# Source0-md5: -
4e897198 28#URL: https://pypi.python.org/pypi/MODULE
7170a7b1 29URL: -
0a48bf0d 30BuildRequires: rpm-pythonprov
038fedf4 31BuildRequires: rpmbuild(macros) >= 1.714
e3bbdd55 32%if %{with python2}
4e897198 33BuildRequires: python-modules
af55af9b 34BuildRequires: python-setuptools
e3bbdd55 35%endif
d328d943 36%if %{with python3}
d328d943 37BuildRequires: python3-modules
af55af9b 38BuildRequires: python3-setuptools
d328d943 39%endif
4e897198
JK
40# when using /usr/bin/env or other in-place substitutions
41#BuildRequires: sed >= 4.0
42# replace with other requires if defined in setup.py
76f14f6a 43Requires: python-modules
4e897198 44BuildArch: noarch
7170a7b1
ER
45BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
46
47%description
48
e6f4b058 49%description -l pl.UTF-8
50
b785d0c9 51%package -n python3-%{pypi_name}
0dd464e7
JK
52Summary: -
53Summary(pl.UTF-8): -
54Group: Libraries/Python
76f14f6a 55Requires: python3-modules
0dd464e7 56
b785d0c9 57%description -n python3-%{pypi_name}
0dd464e7 58
b785d0c9 59%description -n python3-%{pypi_name} -l pl.UTF-8
0dd464e7 60
660096c2 61%package apidocs
2bd7838d
JB
62Summary: API documentation for Python %{module} module
63Summary(pl.UTF-8): Dokumentacja API modułu Pythona %{module}
d328d943
ER
64Group: Documentation
65
660096c2 66%description apidocs
2bd7838d 67API documentation for Pythona %{module} module.
d328d943 68
660096c2 69%description apidocs -l pl.UTF-8
2bd7838d 70Dokumentacja API modułu Pythona %{module}.
d328d943 71
7170a7b1 72%prep
643ec869 73%setup -q -n %{pypi_name}-%{version}
7170a7b1 74
5a020810 75# fix #!/usr/bin/env python -> #!/usr/bin/python:
cb13b64b 76#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
5a020810 77
7170a7b1 78%build
d328d943 79%if %{with python2}
4e897198 80%py_build %{?with_tests:test}
0dd464e7 81%endif
a4ec70eb 82
d328d943 83%if %{with python3}
4e897198 84%py3_build %{?with_tests:test}
d328d943
ER
85%endif
86
87%if %{with doc}
88cd docs
89%{__make} -j1 html
90rm -rf _build/html/_sources
91%endif
92
7170a7b1
ER
93%install
94rm -rf $RPM_BUILD_ROOT
d328d943
ER
95
96%if %{with python2}
4e897198 97%py_install
d328d943 98
caefe7e7
ER
99# when files are installed in other way that standard 'setup.py
100# they need to be (re-)compiled
101# change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
102%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
103%py_comp $RPM_BUILD_ROOT%{py_sitedir}
99f75e1c
JB
104
105%py_postclean
d328d943
ER
106%endif
107
d328d943 108%if %{with python3}
4e897198 109%py3_install
d328d943
ER
110%endif
111
0dd464e7
JK
112# in case there are examples provided
113%if %{with python2}
c7887ed1
ER
114install -d $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
115cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version}
116find $RPM_BUILD_ROOT%{_examplesdir}/python-%{module}-%{version} -name '*.py' \
117 | xargs sed -i '1s|^#!.*python\b|#!%{__python}|'
0dd464e7
JK
118%endif
119%if %{with python3}
b785d0c9
ER
120install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version}
121cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version}
122find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{pypi_name}-%{version} -name '*.py' \
073f936a 123 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
0dd464e7 124%endif
8424aa58 125
7170a7b1
ER
126%clean
127rm -rf $RPM_BUILD_ROOT
128
0dd464e7 129%if %{with python2}
7170a7b1
ER
130%files
131%defattr(644,root,root,755)
132%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
4e897198 133%{py_sitescriptdir}/%{module}
643ec869 134%{py_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
c7887ed1 135%{_examplesdir}/python-%{module}-%{version}
d328d943
ER
136%endif
137
138%if %{with python3}
b785d0c9 139%files -n python3-%{pypi_name}
d328d943
ER
140%defattr(644,root,root,755)
141%doc AUTHORS CHANGES LICENSE
142%{py3_sitescriptdir}/%{module}
643ec869 143%{py3_sitescriptdir}/%{egg_name}-%{version}-py*.egg-info
b785d0c9 144%{_examplesdir}/python3-%{pypi_name}-%{version}
d328d943
ER
145%endif
146
147%if %{with doc}
660096c2 148%files apidocs
d328d943
ER
149%defattr(644,root,root,755)
150%doc docs/_build/html/*
151%endif
This page took 1.355344 seconds and 4 git commands to generate.