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