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