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