]> git.pld-linux.org Git - projects/template-specs.git/blame - python.spec
update dokuwiki template
[projects/template-specs.git] / python.spec
CommitLineData
4cdaa512
ER
1#
2# Conditional build:
b252d5ff 3%bcond_without doc # don't build doc
4cdaa512 4%bcond_without tests # do not perform "make test"
0dd464e7 5%bcond_without python2 # CPython 2.x module
d328d943 6%bcond_without python3 # CPython 3.x module
4cdaa512 7
b81eefa5 8%define module template
7170a7b1
ER
9Summary: -
10Summary(pl.UTF-8): -
3256a2f0 11# Name must match the python module/package name (as in 'import' statement)
b81eefa5 12Name: python-%{module}
7170a7b1
ER
13Version: _
14Release: 0.1
15License: - (enter GPL/GPL v2/GPL v3/LGPL/BSD/BSD-like/other license name here)
6177d217 16Group: Libraries/Python
7170a7b1
ER
17Source0: %{name}-%{version}.tar.gz
18# Source0-md5: -
7170a7b1 19URL: -
dbb3e196 20# remove BR: python-devel for 'noarch' packages.
0a48bf0d 21BuildRequires: rpm-pythonprov
7592d76f
JB
22# if py_postclean is used
23BuildRequires: rpmbuild(macros) >= 1.219
d7036fa0
JB
24# when using /usr/bin/env or other in-place substitutions
25#BuildRequires: sed >= 4.0
606dd359 26# when python3 present
e3bbdd55
ER
27%if %{with python2}
28BuildRequires: python-devel
1a81345d 29BuildRequires: python-setuptools > 7.0
e3bbdd55 30%endif
d328d943
ER
31%if %{with python3}
32BuildRequires: python3-devel
1a81345d 33BuildRequires: python3-setuptools > 7.0
d328d943
ER
34BuildRequires: python3-modules
35%endif
804fc37b 36# Below Rs only work for main package (python2)
10305643 37#Requires: python-libs
38Requires: python-modules
7170a7b1
ER
39#BuildArch: noarch
40BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
41
42%description
43
e6f4b058 44%description -l pl.UTF-8
45
0dd464e7
JK
46%package -n python3-%{module}
47Summary: -
48Summary(pl.UTF-8): -
49Group: Libraries/Python
804fc37b 50Requires: python3-modules
0dd464e7
JK
51
52%description -n python3-%{module}
53
54%description -n python3-%{module} -l pl.UTF-8
55
660096c2 56%package apidocs
d328d943
ER
57Summary: %{module} API documentation
58Summary(pl.UTF-8): Dokumentacja API %{module}
59Group: Documentation
60
660096c2 61%description apidocs
d328d943
ER
62API documentation for %{module}.
63
660096c2 64%description apidocs -l pl.UTF-8
d328d943
ER
65Dokumentacja API %{module}.
66
7170a7b1 67%prep
641675c1 68%setup -q -n %{module}-%{version}
7170a7b1 69
5a020810 70# fix #!/usr/bin/env python -> #!/usr/bin/python:
cb13b64b 71#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
5a020810 72
7170a7b1 73%build
d328d943 74%if %{with python2}
46094905
ER
75# CC/CFLAGS is only for arch packages - remove on noarch packages
76CC="%{__cc}" \
057c1f8a 77CFLAGS="%{rpmcppflags} %{rpmcflags}" \
0dd464e7
JK
78%{__python} setup.py build --build-base build-2 %{?with_tests:test}
79%endif
a4ec70eb 80
d328d943 81%if %{with python3}
0dd464e7
JK
82# CC/CFLAGS is only for arch packages - remove on noarch packages
83CC="%{__cc}" \
057c1f8a 84CFLAGS="%{rpmcppflags} %{rpmcflags}" \
0dd464e7 85%{__python3} setup.py build --build-base build-3 %{?with_tests:test}
d328d943
ER
86%endif
87
88%if %{with doc}
89cd docs
90%{__make} -j1 html
91rm -rf _build/html/_sources
92%endif
93
7170a7b1
ER
94%install
95rm -rf $RPM_BUILD_ROOT
d328d943
ER
96
97%if %{with python2}
98%{__python} setup.py \
99 build --build-base build-2 \
0dd464e7 100 install --skip-build \
e3bbdd55
ER
101 --optimize=2 \
102 --root=$RPM_BUILD_ROOT
d328d943
ER
103
104%py_postclean
105%endif
106
d328d943
ER
107%if %{with python3}
108%{__python3} setup.py \
109 build --build-base build-3 \
0dd464e7 110 install --skip-build \
e3bbdd55
ER
111 --optimize=2 \
112 --root=$RPM_BUILD_ROOT
d328d943
ER
113%endif
114
0dd464e7
JK
115# in case there are examples provided
116%if %{with python2}
117install -d $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
118cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
119%endif
120%if %{with python3}
f33c573b
JK
121install -d $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
122cp -a examples/* $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version}
123find $RPM_BUILD_ROOT%{_examplesdir}/python3-%{module}-%{version} -name '*.py' \
073f936a 124 | xargs sed -i '1s|^#!.*python\b|#!%{__python3}|'
0dd464e7 125%endif
8424aa58 126
0dd464e7
JK
127# when files are installed in other way that standard 'setup.py
128# they need to be (re-)compiled
129## change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
130#%%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
131#%%py_comp $RPM_BUILD_ROOT%{py_sitedir}
132#%%py_postclean
e5a26a61 133
7170a7b1
ER
134%clean
135rm -rf $RPM_BUILD_ROOT
136
0dd464e7 137%if %{with python2}
7170a7b1
ER
138%files
139%defattr(644,root,root,755)
140%doc AUTHORS CREDITS ChangeLog NEWS README THANKS TODO
9a83d846 141# change %{py_sitedir} to %{py_sitescriptdir} for 'noarch' packages!
e5a26a61
ER
142%{py_sitedir}/*.py[co]
143%attr(755,root,root) %{py_sitedir}/*.so
ef0b62a1 144%if "%{py_ver}" > "2.4"
ff6e15ce 145%{py_sitedir}/%{module}-%{version}-py*.egg-info
ef278603 146%endif
8424aa58 147%{_examplesdir}/%{name}-%{version}
d328d943
ER
148%endif
149
150%if %{with python3}
151%files -n python3-%{module}
152%defattr(644,root,root,755)
153%doc AUTHORS CHANGES LICENSE
154%{py3_sitescriptdir}/%{module}
155%{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
f33c573b 156%{_examplesdir}/python3-%{module}-%{version}
d328d943
ER
157%endif
158
159%if %{with doc}
660096c2 160%files apidocs
d328d943
ER
161%defattr(644,root,root,755)
162%doc docs/_build/html/*
163%endif
This page took 4.00084 seconds and 4 git commands to generate.